handlers

package
v0.0.0-...-f805a98 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUserAlreadyExists = "User already exists with the given email"
View Source
var ErrUserNotFound = "No user account exists with given email. Please sign in first"
View Source
var PgDuplicateKeyMsg = "duplicate key value violates unique constraint"
View Source
var PgNoRowsMsg = "no rows in result set"
View Source
var UserCreationFailed = "Unable to create user.Please try again later"

Functions

This section is empty.

Types

type AuthHandler

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

UserHandler wraps instances needed to perform operations on user object

func NewAuthHandler

NewUserHandler returns a new UserHandler instance

func (*AuthHandler) GeneratePassResetCode

func (ah *AuthHandler) GeneratePassResetCode(w http.ResponseWriter, r *http.Request)

GeneratePassResetCode generate a new secret code to reset password.

func (*AuthHandler) Greet

func (ah *AuthHandler) Greet(w http.ResponseWriter, r *http.Request)

Greet request greet request

func (*AuthHandler) Login

func (ah *AuthHandler) Login(w http.ResponseWriter, r *http.Request)

Login handles login request

func (*AuthHandler) MiddlewareValidateAccessToken

func (ah *AuthHandler) MiddlewareValidateAccessToken(next http.Handler) http.Handler

MiddlewareValidateAccessToken validates whether the request contains a bearer token it also decodes and authenticates the given token

func (*AuthHandler) MiddlewareValidateRefreshToken

func (ah *AuthHandler) MiddlewareValidateRefreshToken(next http.Handler) http.Handler

MiddlewareValidateRefreshToken validates whether the request contains a bearer token it also decodes and authenticates the given token

func (*AuthHandler) MiddlewareValidateUser

func (ah *AuthHandler) MiddlewareValidateUser(next http.Handler) http.Handler

MiddlewareValidateUser validates the user in the request

func (*AuthHandler) MiddlewareValidateVerificationData

func (ah *AuthHandler) MiddlewareValidateVerificationData(next http.Handler) http.Handler

MiddlerwareValidateVerificationData validates whether the request contains the email and confirmation code that are required for the verification

func (*AuthHandler) RefreshToken

func (ah *AuthHandler) RefreshToken(w http.ResponseWriter, r *http.Request)

RefreshToken handles refresh token request

func (*AuthHandler) ResetPassword

func (ah *AuthHandler) ResetPassword(w http.ResponseWriter, r *http.Request)

PasswordReset handles the password reset request

func (*AuthHandler) Signup

func (ah *AuthHandler) Signup(w http.ResponseWriter, r *http.Request)

Signup handles signup request

func (*AuthHandler) UpdateUsername

func (ah *AuthHandler) UpdateUsername(w http.ResponseWriter, r *http.Request)

UpdateUsername handles username update request

func (*AuthHandler) VerifyMail

func (ah *AuthHandler) VerifyMail(w http.ResponseWriter, r *http.Request)

VerifyMail verifies the provided confirmation code and set the User state to verified

func (*AuthHandler) VerifyPasswordReset

func (ah *AuthHandler) VerifyPasswordReset(w http.ResponseWriter, r *http.Request)

VerifyPasswordReset verifies the code provided for password reset

type AuthResponse

type AuthResponse struct {
	RefreshToken string `json:"refresh_token"`
	AccessToken  string `json:"access_token"`
	Username     string `json:"username"`
}

type CodeVerificationReq

type CodeVerificationReq struct {
	Code string `json:"code"`
	Type string `json:"type"`
}

type GenericResponse

type GenericResponse struct {
	Status  bool        `json:"status"`
	Message string      `json:"message"`
	Data    interface{} `json:"data"`
}

GenericResponse is the format of our response

type PasswordResetReq

type PasswordResetReq struct {
	Password   string `json:"password"`
	PasswordRe string `json:"password_re"`
	Code       string `json:"code"`
}

type TokenResponse

type TokenResponse struct {
	RefreshToken string `json:"refresh_token"`
	AccessToken  string `json:"access_token"`
}

Below data types are used for encoding and decoding b/t go types and json

type UserIDKey

type UserIDKey struct{}

UserIDKey is used as a key for storing the UserID in context at middleware

type UserKey

type UserKey struct{}

UserKey is used as a key for storing the User object in context at middleware

type UsernameUpdate

type UsernameUpdate struct {
	Username string `json:"username"`
}

type ValidationError

type ValidationError struct {
	Errors []string `json:"errors"`
}

ValidationError is a collection of validation error messages

type VerificationDataKey

type VerificationDataKey struct{}

VerificationDataKey is used as the key for storing the VerificationData in context at middleware

Jump to

Keyboard shortcuts

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