users

package
v0.0.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 25, 2023 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FacebookUser

type FacebookUser struct {
	ID    string `json:"id"`
	Name  string `json:"name"`
	Email string `json:"email"`
}

type User

type User struct {
	ID                primitive.ObjectID   `bson:"_id"`
	CreatedOn         time.Time            `bson:"createdOn"`
	UpdatedOn         *time.Time           `bson:"updatedOn,omitempty"`
	IsActive          bool                 `bson:"isActive"`
	IsVerified        bool                 `bson:"isVerified"`
	VerificationToken string               `bson:"verificationToken,omitempty"`
	Username          string               `bson:"username"`
	Email             string               `bson:"email"`
	Password          string               `bson:"password"`
	RecoveryCode      string               `bson:"recoveryCode,omitempty"`
	ResettingCode     string               `bson:"resettingCode,omitempty"`
	Role              primitive.ObjectID   `bson:"role,omitempty"`
	Rights            []primitive.ObjectID `bson:"rights,omitempty"`
}

func NewUser

func NewUser(verificationToken string, username string, email string, passwordHash string, role *permissions.Role, rights []*permissions.Right) *User

type UserHandlers

type UserHandlers struct {
	// contains filtered or unexported fields
}

func NewUserHandlers

func NewUserHandlers(userService *UserService, roleService *permissions.RoleService, rightService *permissions.RightService, log *zap.Logger, blunder *blunder.Blunder) *UserHandlers

func (*UserHandlers) CreateAdmin

func (h *UserHandlers) CreateAdmin(c *gin.Context)

CreateAdminHandler godoc @Summary Create admin @Description create admin @Tags identity @Accept json @Produce json @Param data body CreateUserPayload true "data" @Success 201 {object} CreateUserResponse @Failure 400 {object} blunder.HTTPErrorResponse @Failure 404 {object} blunder.HTTPErrorResponse @Failure 500 {object} blunder.HTTPErrorResponse @Router /admins [post]

func (*UserHandlers) CreateUser

func (h *UserHandlers) CreateUser(c *gin.Context)

CreateUserHandler godoc @Summary Create user @Description create user @Tags identity @Accept json @Produce json @Param data body CreateUserPayload true "data" @Success 201 {object} CreateUserResponse @Failure 400 {object} blunder.HTTPErrorResponse @Failure 404 {object} blunder.HTTPErrorResponse @Failure 500 {object} blunder.HTTPErrorResponse @Router /users [post]

func (*UserHandlers) DeleteUser

func (h *UserHandlers) DeleteUser(c *gin.Context)

DeleteUserHandler godoc @Summary Delete user @Description delete user @Tags identity @Accept json @Produce json @Security OAuth2Application @Param userID path int true "1" @Router /users/{userId} [delete]

func (*UserHandlers) ExchangeRecoveryCode

func (h *UserHandlers) ExchangeRecoveryCode(c *gin.Context)

ExchangeRecoveryCodeHandler godoc @Summary Exchange recovery code @Description exchange recovery code @Tags identity @Accept json @Produce json @Param data body ExchangeCodeRequestPayload true "data" @Success 200 {object} ExchangeCodeResponse @Router /password-recovery/exchange [post]

func (*UserHandlers) FacebookCallback

func (h *UserHandlers) FacebookCallback(c *gin.Context)

FacebookCallbackHandler godoc @Summary Facebook Callback @Description Facebook callback @Tags identity @Accept json @Produce json @Param data body CreateUserPayload true "data" @Success 201 {object} CreateUserResponse @Router /facebook/callback [post]

func (*UserHandlers) GetToken

func (h *UserHandlers) GetToken(c *gin.Context)

GetTokenHandler godoc @Summary Get token @Description get token @Tags identity @Accept json @Produce json @Security BasicAuth @Param type query string false "refresh_token" @Success 200 {object} TokenResponse @Router /token [post]

func (*UserHandlers) GetUserById

func (h *UserHandlers) GetUserById(c *gin.Context)

GetUserByIdHandler godoc @Summary Get user by id @Description get user by id @Tags identity @Accept json @Produce json @Security OAuth2Application @Param userID path int true "1" @Success 200 {object} UserResponse @Router /users/{userId} [get]

func (*UserHandlers) GetUsers

func (h *UserHandlers) GetUsers(c *gin.Context)

GetUsersHandler godoc @Summary Get users @Description get users @Tags identity @Accept json @Produce json @Security OAuth2Application @Success 200 {array} UserResponse @Router /users [get]

func (*UserHandlers) JWKS added in v0.0.7

func (h *UserHandlers) JWKS(c *gin.Context)

GetJWKSHandler godoc @Summary Get jwks @Description get jwks @Tags identity @Accept json @Produce json @Security BasicAuth @Success 200 {object} responses.Jwks @Router /.well-known/jwks.json [get]

func (*UserHandlers) PasswordRecovery

func (h *UserHandlers) PasswordRecovery(c *gin.Context)

EmailRecoveryCodeHandler godoc @Summary Email recovery code @Description email recovery code @Tags identity @Accept json @Produce json @Param data body RecoveryEmailPayload true "data" @Router /password-recovery/email [post]

func (*UserHandlers) ResetPassword

func (h *UserHandlers) ResetPassword(c *gin.Context)

ResetPasswordHandler godoc @Summary Reset password @Description reset password @Tags identity @Accept json @Produce json @Param data body PasswordResetPayload true "data" @Router /password-recovery/reset [post]

func (*UserHandlers) UpdateUser

func (h *UserHandlers) UpdateUser(c *gin.Context)

UpdateUserHandler godoc @Summary Update user @Description update user @Tags identity @Accept json @Produce json @Security OAuth2Application @Param userID path string true "1" @Param data body UpdateUserPayload true "data" @Success 200 {object} UserResponse @Router /users/{userId} [patch]

func (*UserHandlers) VerifyEmail

func (h *UserHandlers) VerifyEmail(c *gin.Context)

VerifyEmailHandler godoc @Summary Verify email @Description verify email @Tags identity @Accept json @Produce json @Param token path string true "1" @Router /verify/{token} [post]

type UserRepository

type UserRepository struct {
	*passport.MongoRepository
}

func NewUserRepository

func NewUserRepository(client *mongo.Client, conf *passport.Config, roleRepository *permissions.RoleRepository) *UserRepository

func (*UserRepository) GetAll

func (r *UserRepository) GetAll(ctx context.Context) ([]*User, error)

func (*UserRepository) GetByEmail

func (r *UserRepository) GetByEmail(ctx context.Context, email string) (*User, error)

func (*UserRepository) GetByUsername

func (r *UserRepository) GetByUsername(ctx context.Context, username string) (*User, error)

func (*UserRepository) GetRecoveryCode

func (r *UserRepository) GetRecoveryCode(ctx context.Context, id primitive.ObjectID) (string, error)

func (*UserRepository) GetResettingCode

func (r *UserRepository) GetResettingCode(ctx context.Context, id primitive.ObjectID) (string, error)

func (*UserRepository) ResetPassword

func (r *UserRepository) ResetPassword(ctx context.Context, id primitive.ObjectID, passwordHash string) error

func (*UserRepository) SetRecoveryCode

func (r *UserRepository) SetRecoveryCode(ctx context.Context, id primitive.ObjectID, code string) error

func (*UserRepository) SetResettingCode

func (r *UserRepository) SetResettingCode(ctx context.Context, id primitive.ObjectID, code string) error

func (*UserRepository) Update

func (r *UserRepository) Update(ctx context.Context, u *User) error

func (*UserRepository) Verify

func (r *UserRepository) Verify(ctx context.Context, token string) error

type UserService

type UserService struct {
	// contains filtered or unexported fields
}

func NewUserService

func NewUserService(notificationFacade *facade.NotificationFacade, repository *UserRepository, roleService *permissions.RoleService, rightService *permissions.RightService, conf *passport.Config, log *zap.Logger) *UserService

func (*UserService) BasicAuthToken

func (s *UserService) BasicAuthToken(ctx context.Context, username, password string) (string, string, int64, error)

func (*UserService) CreateUser

func (s *UserService) CreateUser(ctx context.Context, username string, email string, password string, r string, isAdmin bool, rr []string) (*User, error)

func (*UserService) DeleteUser

func (s *UserService) DeleteUser(ctx context.Context, id primitive.ObjectID) (bool, error)

func (*UserService) ExchangeRecoveryCode

func (s *UserService) ExchangeRecoveryCode(ctx context.Context, email string, code string) (string, error)

ExchangeRecoveryCode exchanges recovery code for a password resetting one

func (*UserService) GetById

func (s *UserService) GetById(ctx context.Context, id primitive.ObjectID) (*User, error)

func (*UserService) GetPublicKey added in v0.0.7

func (s *UserService) GetPublicKey() (*rsa.PublicKey, error)

func (*UserService) GetUserByEmail

func (s *UserService) GetUserByEmail(ctx context.Context, email string) (*User, error)

func (*UserService) GetUserById

func (s *UserService) GetUserById(ctx context.Context, id primitive.ObjectID) (*User, error)

func (*UserService) GetUserByToken

func (s *UserService) GetUserByToken(ctx context.Context, t string) (*User, error)

func (*UserService) GetUserByUsername

func (s *UserService) GetUserByUsername(ctx context.Context, username string) (*User, error)

func (*UserService) GetUsers

func (s *UserService) GetUsers(ctx context.Context) ([]*User, error)

func (*UserService) IssueAccessToken

func (s *UserService) IssueAccessToken(user *User) (string, int64, error)

func (*UserService) IssueRefreshToken

func (s *UserService) IssueRefreshToken(user *User) (string, error)

func (*UserService) LoadPermisions

func (s *UserService) LoadPermisions(ctx context.Context, user *User) (*permissions.Role, []permissions.Right, error)

func (*UserService) MapToUserClaims

func (s *UserService) MapToUserClaims(u *User) *passport.UserClaims

func (*UserService) MapToUserResponse

func (s *UserService) MapToUserResponse(ctx context.Context, u *User) (*responses.UserResponse, error)

func (*UserService) RefreshToken

func (s *UserService) RefreshToken(ctx context.Context, t string) (string, int64, error)

RefreshToken refreshes existing token

func (*UserService) ResetPassword

func (s *UserService) ResetPassword(ctx context.Context, email string, code string, newPassword string) error

func (*UserService) SendRecoveryEmail

func (s *UserService) SendRecoveryEmail(ctx context.Context, email string)

func (*UserService) UpdateUser

func (s *UserService) UpdateUser(ctx context.Context, id primitive.ObjectID, email string, username string, isActive bool, changePassword bool) (*User, error)

func (*UserService) ValidateToken

func (s *UserService) ValidateToken(ctx context.Context, t string) (*passport.UserClaims, error)

func (*UserService) VerifyEmail

func (s *UserService) VerifyEmail(ctx context.Context, token string) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL