base

package
v0.0.0-...-702f6d9 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Auth

func Auth(params types.RouteParams)

func DeleteToken

func DeleteToken(db *gorm.DB, token string, tokenType models.VerificationType) *errors.Error

func GetActiveTokenByUserID

func GetActiveTokenByUserID(db *gorm.DB, userID uuid.UUID, tokenType models.VerificationType) (*models.Verification, *errors.Error)

func GetToken

func GetToken(db *gorm.DB, token string, tokenType models.VerificationType) (*models.Verification, *errors.Error)

func SaveToken

func SaveToken(db *gorm.DB, userID uuid.UUID, token string, tokenType models.VerificationType, expiry time.Time) *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) GetRole

func (a *AuthService) GetRole(id string) (*models.UserRole, *errors.Error)

func (*AuthService) Login

func (*AuthService) Logout

func (a *AuthService) Logout(c *fiber.Ctx) *errors.Error

func (*AuthService) Refresh

func (a *AuthService) Refresh(refreshToken string) (*auth.Token, *errors.Error)

func (*AuthService) SendCode

func (a *AuthService) SendCode(email string) *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

Jump to

Keyboard shortcuts

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