Documentation ¶
Index ¶
- type FacebookUser
- type User
- type UserHandlers
- func (h *UserHandlers) CreateAdmin(c *gin.Context)
- func (h *UserHandlers) CreateUser(c *gin.Context)
- func (h *UserHandlers) DeleteUser(c *gin.Context)
- func (h *UserHandlers) ExchangeRecoveryCode(c *gin.Context)
- func (h *UserHandlers) FacebookCallback(c *gin.Context)
- func (h *UserHandlers) GetToken(c *gin.Context)
- func (h *UserHandlers) GetUserById(c *gin.Context)
- func (h *UserHandlers) GetUsers(c *gin.Context)
- func (h *UserHandlers) JWKS(c *gin.Context)
- func (h *UserHandlers) PasswordRecovery(c *gin.Context)
- func (h *UserHandlers) ResetPassword(c *gin.Context)
- func (h *UserHandlers) UpdateUser(c *gin.Context)
- func (h *UserHandlers) VerifyEmail(c *gin.Context)
- type UserRepository
- func (r *UserRepository) GetAll(ctx context.Context) ([]*User, error)
- func (r *UserRepository) GetByEmail(ctx context.Context, email string) (*User, error)
- func (r *UserRepository) GetByUsername(ctx context.Context, username string) (*User, error)
- func (r *UserRepository) GetRecoveryCode(ctx context.Context, id primitive.ObjectID) (string, error)
- func (r *UserRepository) GetResettingCode(ctx context.Context, id primitive.ObjectID) (string, error)
- func (r *UserRepository) ResetPassword(ctx context.Context, id primitive.ObjectID, passwordHash string) error
- func (r *UserRepository) SetRecoveryCode(ctx context.Context, id primitive.ObjectID, code string) error
- func (r *UserRepository) SetResettingCode(ctx context.Context, id primitive.ObjectID, code string) error
- func (r *UserRepository) Update(ctx context.Context, u *User) error
- func (r *UserRepository) Verify(ctx context.Context, token string) error
- type UserService
- func (s *UserService) BasicAuthToken(ctx context.Context, username, password string) (string, string, int64, error)
- func (s *UserService) CreateUser(ctx context.Context, username string, email string, password string, r string, ...) (*User, error)
- func (s *UserService) DeleteUser(ctx context.Context, id primitive.ObjectID) (bool, error)
- func (s *UserService) ExchangeRecoveryCode(ctx context.Context, email string, code string) (string, error)
- func (s *UserService) GetById(ctx context.Context, id primitive.ObjectID) (*User, error)
- func (s *UserService) GetPublicKey() (*rsa.PublicKey, error)
- func (s *UserService) GetUserByEmail(ctx context.Context, email string) (*User, error)
- func (s *UserService) GetUserById(ctx context.Context, id primitive.ObjectID) (*User, error)
- func (s *UserService) GetUserByToken(ctx context.Context, t string) (*User, error)
- func (s *UserService) GetUserByUsername(ctx context.Context, username string) (*User, error)
- func (s *UserService) GetUsers(ctx context.Context) ([]*User, error)
- func (s *UserService) IssueAccessToken(user *User) (string, int64, error)
- func (s *UserService) IssueRefreshToken(user *User) (string, error)
- func (s *UserService) LoadPermisions(ctx context.Context, user *User) (*permissions.Role, []permissions.Right, error)
- func (s *UserService) MapToUserClaims(u *User) *passport.UserClaims
- func (s *UserService) MapToUserResponse(ctx context.Context, u *User) (*responses.UserResponse, error)
- func (s *UserService) RefreshToken(ctx context.Context, t string) (string, int64, error)
- func (s *UserService) ResetPassword(ctx context.Context, email string, code string, newPassword string) error
- func (s *UserService) SendRecoveryEmail(ctx context.Context, email string)
- func (s *UserService) UpdateUser(ctx context.Context, id primitive.ObjectID, email string, username string, ...) (*User, error)
- func (s *UserService) ValidateToken(ctx context.Context, t string) (*passport.UserClaims, error)
- func (s *UserService) VerifyEmail(ctx context.Context, token string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FacebookUser ¶
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"` }
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 (*UserRepository) GetByUsername ¶
func (*UserRepository) GetRecoveryCode ¶
func (*UserRepository) GetResettingCode ¶
func (*UserRepository) ResetPassword ¶
func (*UserRepository) SetRecoveryCode ¶
func (*UserRepository) SetResettingCode ¶
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 (*UserService) CreateUser ¶
func (*UserService) DeleteUser ¶
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) GetPublicKey ¶ added in v0.0.7
func (s *UserService) GetPublicKey() (*rsa.PublicKey, error)
func (*UserService) GetUserByEmail ¶
func (*UserService) GetUserById ¶
func (*UserService) GetUserByToken ¶
func (*UserService) GetUserByUsername ¶
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 ¶
RefreshToken refreshes existing token
func (*UserService) ResetPassword ¶
func (*UserService) SendRecoveryEmail ¶
func (s *UserService) SendRecoveryEmail(ctx context.Context, email string)
func (*UserService) UpdateUser ¶
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