Documentation
¶
Index ¶
- Variables
- type AuthHandler
- func (ah *AuthHandler) GeneratePassResetCode(w http.ResponseWriter, r *http.Request)
- func (ah *AuthHandler) Greet(w http.ResponseWriter, r *http.Request)
- func (ah *AuthHandler) Login(w http.ResponseWriter, r *http.Request)
- func (ah *AuthHandler) MiddlewareValidateAccessToken(next http.Handler) http.Handler
- func (ah *AuthHandler) MiddlewareValidateRefreshToken(next http.Handler) http.Handler
- func (ah *AuthHandler) MiddlewareValidateUser(next http.Handler) http.Handler
- func (ah *AuthHandler) MiddlewareValidateVerificationData(next http.Handler) http.Handler
- func (ah *AuthHandler) RefreshToken(w http.ResponseWriter, r *http.Request)
- func (ah *AuthHandler) ResetPassword(w http.ResponseWriter, r *http.Request)
- func (ah *AuthHandler) Signup(w http.ResponseWriter, r *http.Request)
- func (ah *AuthHandler) UpdateUsername(w http.ResponseWriter, r *http.Request)
- func (ah *AuthHandler) VerifyMail(w http.ResponseWriter, r *http.Request)
- func (ah *AuthHandler) VerifyPasswordReset(w http.ResponseWriter, r *http.Request)
- type AuthResponse
- type CodeVerificationReq
- type GenericResponse
- type PasswordResetReq
- type TokenResponse
- type UserIDKey
- type UserKey
- type UsernameUpdate
- type ValidationError
- type VerificationDataKey
Constants ¶
This section is empty.
Variables ¶
var ErrUserAlreadyExists = "User already exists with the given email"
var ErrUserNotFound = "No user account exists with given email. Please sign in first"
var PgDuplicateKeyMsg = "duplicate key value violates unique constraint"
var PgNoRowsMsg = "no rows in result set"
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 ¶
func NewAuthHandler(d data.GoDB, l zap.Logger, c *utils.Configurations, v *data.Validation, auth services.Authentication, mail services.MailService) *AuthHandler
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 CodeVerificationReq ¶
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 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