Documentation ¶
Index ¶
- func Auth(params types.RouteParams)
- func DeleteToken(db *gorm.DB, token string, tokenType models.VerificationType) *errors.Error
- func GetActiveTokenByUserID(db *gorm.DB, userID uuid.UUID, tokenType models.VerificationType) (*models.Verification, *errors.Error)
- func GetToken(db *gorm.DB, token string, tokenType models.VerificationType) (*models.Verification, *errors.Error)
- func SaveToken(db *gorm.DB, userID uuid.UUID, token string, tokenType models.VerificationType, ...) *errors.Error
- type AuthController
- func (a *AuthController) ForgotPassword(c *fiber.Ctx) error
- func (a *AuthController) Login(c *fiber.Ctx) error
- func (a *AuthController) Logout(c *fiber.Ctx) error
- func (a *AuthController) Refresh(c *fiber.Ctx) error
- func (a *AuthController) SendCode(c *fiber.Ctx) error
- func (a *AuthController) VerifyEmail(c *fiber.Ctx) error
- func (a *AuthController) VerifyPasswordResetToken(c *fiber.Ctx) error
- type AuthService
- func (a *AuthService) ForgotPassword(email string) *errors.Error
- func (a *AuthService) GetRole(id string) (*models.UserRole, *errors.Error)
- func (a *AuthService) Login(loginBody models.LoginUserResponseBody) (*models.User, *auth.Token, *errors.Error)
- func (a *AuthService) Logout(c *fiber.Ctx) *errors.Error
- func (a *AuthService) Refresh(refreshToken string) (*auth.Token, *errors.Error)
- func (a *AuthService) SendCode(email string) *errors.Error
- func (a *AuthService) VerifyEmail(emailBody models.VerifyEmailRequestBody) *errors.Error
- func (a *AuthService) VerifyPasswordResetToken(passwordBody models.VerifyPasswordResetTokenRequestBody) *errors.Error
- type AuthServiceInterface
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Auth ¶
func Auth(params types.RouteParams)
func DeleteToken ¶
func GetActiveTokenByUserID ¶
func GetActiveTokenByUserID(db *gorm.DB, userID uuid.UUID, tokenType models.VerificationType) (*models.Verification, *errors.Error)
Types ¶
type AuthController ¶
type AuthController struct {
// contains filtered or unexported fields
}
func NewAuthController ¶
func NewAuthController(authService AuthServiceInterface) *AuthController
func (*AuthController) ForgotPassword ¶
func (a *AuthController) ForgotPassword(c *fiber.Ctx) error
ForgotPassword godoc
@Summary Generates a password reset token @Description Generates a password reset token @ID forgot-password @Tags auth @Accept json @Produce json @Param email body string true "Email" @Success 200 {object} utilities.SuccessResponse @Failure 400 {object} errors.Error @Failure 429 {object} errors.Error @Failure 500 {object} errors.Error @Router /auth/forgot-password [post]
func (*AuthController) Login ¶
func (a *AuthController) Login(c *fiber.Ctx) error
Login godoc
@Summary Logs in a user @Description Logs in a user @ID login-user @Tags auth @Accept json @Produce json @Param loginBody body models.LoginUserResponseBody true "Login Body" @Success 200 {object} models.User @Failure 400 {object} errors.Error @Failure 404 {object} errors.Error @Failure 500 {object} errors.Error @Router /auth/login [post]
func (*AuthController) Logout ¶
func (a *AuthController) Logout(c *fiber.Ctx) error
Logout godoc
@Summary Logs out a user @Description Logs out a user @ID logout-user @Tags auth @Accept json @Produce json @Success 200 {object} utilities.SuccessResponse @Router /auth/logout [post]
func (*AuthController) Refresh ¶
func (a *AuthController) Refresh(c *fiber.Ctx) error
Refresh godoc
@Summary Refreshes a user's access token @Description Refreshes a user's access token @ID refresh-user @Tags auth @Accept json @Produce json @Success 200 {object} utilities.SuccessResponse @Failure 400 {object} errors.Error @Failure 404 {object} errors.Error @Failure 500 {object} errors.Error @Router /auth/refresh [post]
func (*AuthController) SendCode ¶
func (a *AuthController) SendCode(c *fiber.Ctx) error
SendCode godoc
@Summary Sends a verification code @Description Sends a verification code @ID send-verification-code @Tags auth @Accept json @Produce json @Param email body string true "Email" @Success 200 {object} utilities.SuccessResponse @Failure 400 {object} errors.Error @Failure 429 {object} errors.Error @Failure 500 {object} errors.Error @Router /auth/send-code [post]
func (*AuthController) VerifyEmail ¶
func (a *AuthController) VerifyEmail(c *fiber.Ctx) error
VerifyEmail godoc
@Summary Verifies an email @Description Verifies an email @ID verify-email @Tags auth @Accept json @Produce json @Param tokenBody body models.VerifyEmailRequestBody true "Email Verification Token Body" @Success 200 {object} utilities.SuccessResponse @Failure 400 {object} errors.Error @Failure 429 {object} errors.Error @Failure 500 {object} errors.Error @Router /auth/verify-email [post]
func (*AuthController) VerifyPasswordResetToken ¶
func (a *AuthController) VerifyPasswordResetToken(c *fiber.Ctx) error
VerifyPasswordResetToken godoc
@Summary Verifies a password reset token @Description Verifies a password reset token @ID verify-password-reset-token @Tags auth @Accept json @Produce json @Param tokenBody body models.VerifyPasswordResetTokenRequestBody true "Password Reset Token Body" @Security Bearer @Success 200 {object} utilities.SuccessResponse @Failure 400 {object} errors.Error @Failure 429 {object} errors.Error @Failure 500 {object} errors.Error @Router /auth/verify-reset [post]
type AuthService ¶
type AuthService struct {
types.ServiceParams
}
func (*AuthService) ForgotPassword ¶
func (a *AuthService) ForgotPassword(email string) *errors.Error
func (*AuthService) Login ¶
func (a *AuthService) Login(loginBody models.LoginUserResponseBody) (*models.User, *auth.Token, *errors.Error)
func (*AuthService) Logout ¶
func (a *AuthService) Logout(c *fiber.Ctx) *errors.Error
func (*AuthService) VerifyEmail ¶
func (a *AuthService) VerifyEmail(emailBody models.VerifyEmailRequestBody) *errors.Error
func (*AuthService) VerifyPasswordResetToken ¶
func (a *AuthService) VerifyPasswordResetToken(passwordBody models.VerifyPasswordResetTokenRequestBody) *errors.Error
type AuthServiceInterface ¶
type AuthServiceInterface interface { GetRole(id string) (*models.UserRole, *errors.Error) Login(userBody models.LoginUserResponseBody) (*models.User, *auth.Token, *errors.Error) Refresh(refreshToken string) (*auth.Token, *errors.Error) Logout(c *fiber.Ctx) *errors.Error SendCode(email string) *errors.Error VerifyEmail(emailBody models.VerifyEmailRequestBody) *errors.Error ForgotPassword(email string) *errors.Error VerifyPasswordResetToken(passwordBody models.VerifyPasswordResetTokenRequestBody) *errors.Error }
func NewAuthService ¶
func NewAuthService(serviceParams types.ServiceParams) AuthServiceInterface