handler

package
v1.6.391 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package handler sits in between controller and database services.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Activate2FA

func Activate2FA(claims middleware.MyCustomClaims, authPayload model.AuthPayload) (httpResponse model.HTTPResponse, httpStatusCode int)

Activate2FA handles jobs for controller.Activate2FA

func CreateBackup2FA

func CreateBackup2FA(claims middleware.MyCustomClaims, authPayload model.AuthPayload) (httpResponse model.HTTPResponse, httpStatusCode int)

CreateBackup2FA receives task from controller.CreateBackup2FA. If 2FA is already enabled for the user, it generates secret backup codes for the user.

Required: valid JWT with parameter "twoFA": "verified"

func CreateUserAuth

func CreateUserAuth(auth model.Auth) (httpResponse model.HTTPResponse, httpStatusCode int)

CreateUserAuth receives tasks from controller.CreateUserAuth. After email validation, it creates a new user account. It supports both the legacy way of saving user email in plaintext and the recommended way of applying encryption at rest.

func CreateVerificationEmail

func CreateVerificationEmail(payload model.AuthPayload) (httpResponse model.HTTPResponse, httpStatusCode int)

CreateVerificationEmail handles jobs for controller.CreateVerificationEmail

func Deactivate2FA

func Deactivate2FA(claims middleware.MyCustomClaims, authPayload model.AuthPayload) (httpResponse model.HTTPResponse, httpStatusCode int)

Deactivate2FA handles jobs for controller.Deactivate2FA

func GetUnverifiedEmail

func GetUnverifiedEmail(claims middleware.MyCustomClaims) (httpResponse model.HTTPResponse, httpStatusCode int)

GetUnverifiedEmail receives tasks from controller.GetUnverifiedEmail

It retrieves unverified email information for a given user.

func Login

func Login(payload model.AuthPayload) (httpResponse model.HTTPResponse, httpStatusCode int)

Login receives tasks from controller.Login. After authentication, it returns new access and refresh tokens.

func Logout

func Logout(jtiAccess, jtiRefresh string, expAccess, expRefresh int64) (httpResponse model.HTTPResponse, httpStatusCode int)

Logout handles jobs for controller.Logout

func PasswordForgot

func PasswordForgot(authPayload model.AuthPayload) (httpResponse model.HTTPResponse, httpStatusCode int)

PasswordForgot handles jobs for controller.PasswordForgot

func PasswordRecover

func PasswordRecover(authPayload model.AuthPayload) (httpResponse model.HTTPResponse, httpStatusCode int)

PasswordRecover handles jobs for controller.PasswordRecover

func PasswordUpdate

func PasswordUpdate(claims middleware.MyCustomClaims, authPayload model.AuthPayload) (httpResponse model.HTTPResponse, httpStatusCode int)

PasswordUpdate handles jobs for controller.PasswordUpdate

func Refresh

func Refresh(claims middleware.MyCustomClaims) (httpResponse model.HTTPResponse, httpStatusCode int)

Refresh receives tasks from controller.Refresh and returns new pair of tokens (access and refresh tokens).

func ResendVerificationCodeToModifyActiveEmail

func ResendVerificationCodeToModifyActiveEmail(claims middleware.MyCustomClaims) (httpResponse model.HTTPResponse, httpStatusCode int)

ResendVerificationCodeToModifyActiveEmail receives tasks from controller.ResendVerificationCodeToModifyActiveEmail

func Setup2FA

func Setup2FA(claims middleware.MyCustomClaims, authPayload model.AuthPayload) (httpResponse model.HTTPResponse, httpStatusCode int)

Setup2FA handles jobs for controller.Setup2FA

func UpdateEmail

func UpdateEmail(claims middleware.MyCustomClaims, req model.TempEmail) (httpResponse model.HTTPResponse, httpStatusCode int)

UpdateEmail receives tasks from controller.UpdateEmail.

step 1: validate email format

step 2: verify that this email is not registered to anyone

step 3: load user credentials

step 4: verify user password

step 5: calculate hash of the new email

step 6: read 'temp_emails' table

step 7: verify that this is not a repeated request for the same email

step 8: populate model with data to be processed in database

step 9: send a verification email if required by the app

func Validate2FA

func Validate2FA(claims middleware.MyCustomClaims, authPayload model.AuthPayload) (httpResponse model.HTTPResponse, httpStatusCode int)

Validate2FA handles jobs for controller.Validate2FA

func ValidateBackup2FA

func ValidateBackup2FA(claims middleware.MyCustomClaims, authPayload model.AuthPayload) (httpResponse model.HTTPResponse, httpStatusCode int)

ValidateBackup2FA receives task from controller.ValidateBackup2FA. User with 2FA enabled account can verify using their secret backup code when they do not have access to their OTP generator app or device.

Required: valid JWT with parameter "twoFA": "on"

func VerifyEmail

func VerifyEmail(payload model.AuthPayload) (httpResponse model.HTTPResponse, httpStatusCode int)

VerifyEmail handles jobs for controller.VerifyEmail

func VerifyUpdatedEmail

func VerifyUpdatedEmail(payload model.AuthPayload) (httpResponse model.HTTPResponse, httpStatusCode int)

VerifyUpdatedEmail receives tasks from controller.VerifyUpdatedEmail

- verify newly added email address

- update user email address

- delete temporary data from database after verification process is done

Types

This section is empty.

Jump to

Keyboard shortcuts

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