user

package
v0.0.0-...-f06a132 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateUserRequest

type CreateUserRequest struct {
	Name     string `json:"name" binding:"required"`
	Email    string `json:"email" binding:"required,email"`
	Password string `json:"password" binding:"required"`
}

type CreateUserResponse

type CreateUserResponse struct {
	ID uint `json:"id"`
}

type ResendVerificationEmailRequest

type ResendVerificationEmailRequest struct {
	Email    string `json:"email" binding:"required,email"`
	Password string `json:"password" binding:"required"`
}

type ResetPWAuthCodeExchangeRequest

type ResetPWAuthCodeExchangeRequest struct {
	Email string `json:"email"`
	Token string `json:"token"`
}

type ResetPWAuthCodeExchangeResponse

type ResetPWAuthCodeExchangeResponse struct {
	AuthCode string `json:"auth_code"`
}

type ResetPasswordRequest

type ResetPasswordRequest struct {
	Email string `json:"email"`
}

type SetNewPWRequest

type SetNewPWRequest struct {
	Email       string `json:"email"`
	AuthCode    string `json:"auth_code"`
	NewPassword string `json:"new_password"`
}

type User

type User struct {
	Uuid        string `json:"uuid"`
	Name        string `json:"name"`
	Email       string `json:"email"`
	AccountType int    `json:"account_type"`
	IsVerified  bool   `json:"is_verified"`
}

func NewUserFromSvcUser

func NewUserFromSvcUser(svcUser *user.User) User

type UserHandler

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

func InitUserHandler

func InitUserHandler(userService *user.UserService) *UserHandler

func (*UserHandler) CreateUser

func (h *UserHandler) CreateUser(c *gin.Context)

@Summary Create user @Description Create new user @Tags user @Accept json @Param req body CreateUserRequest true "Create user data" @Produce json @Failure 409 {object} httpresp.StandardResponse "User with same email already exists" @Success 200 {object} httpresp.StandardDataResponse{data=CreateUserResponse} @Router /user [post]

func (*UserHandler) GetUser

func (h *UserHandler) GetUser(c *gin.Context)

@Summary Get basic user information @Description Get basic user information (protected endpoint) @Tags user,authRequired @Param uuid query string true "UUID" @Success 200 {object} httpresp.StandardDataResponse{data=User} @Failure 404 {object} httpresp.StandardResponse "User not found" @Router /user/{uuid} [get]

func (*UserHandler) ResendVerificationEmail

func (h *UserHandler) ResendVerificationEmail(c *gin.Context)

@Summary Resned verification email @Description Resends verification email while invalidating previous verification link @Tags user @Param req body ResendVerificationEmailRequest true "Email and password must be provided to authenticate before sending" @Accept json @Produce json @Success 200 {object} httpresp.StandardResponse @Failure 429 {object} httpresp.StandardResponse "Too many requests made in a short period of time (2 mins)" @Failure 405 {object} httpresp.StandardResponse "User already verified" @Router /user/verify/resend_email [post]

func (*UserHandler) ResetPassword

func (h *UserHandler) ResetPassword(c *gin.Context)

@Summary Reset password @Description Starts reset password process by generating and sending 6-digit token to provided email if account exists @Tags user @Accept json @Param req body ResetPasswordRequest true "Specify email of account to reset" @Produce json @Success 200 {object} httpresp.StandardResponse @Router /user/reset_password [post]

func (*UserHandler) ResetPasswordAuthCodeExchange

func (h *UserHandler) ResetPasswordAuthCodeExchange(c *gin.Context)

@Summary Reset password auth code exchange @Description Verify 6-digit token and exchange token with auth code to set new password @Tags user @Accept json @Param req body ResetPWAuthCodeExchangeRequest true "Specify both email and token" @Produce json @Failure 401 {object} httpresp.StandardResponse "Token rejected" @Success 200 {object} httpresp.StandardDataResponse{data=ResetPWAuthCodeExchangeResponse} @Router /user/reset_password/token_exchange [post]

func (*UserHandler) SetNewPassword

func (h *UserHandler) SetNewPassword(c *gin.Context)

Final API call for reset password process (sets new password) @Summary Set new password @Description Final API call for reset password process. Set new password, authenticating using auth code. @Tags user @Accept json @Param req body SetNewPWRequest true "Specify new password for account" @Produce json @Failure 401 {object} httpresp.StandardResponse "Auth code rejected" @Success 200 {object} httpresp.StandardResponse @Router /user/reset_password/set_password [post]

func (*UserHandler) VerifyEmail

func (h *UserHandler) VerifyEmail(c *gin.Context)

@Summary Verify email @Description Handles verification link for email @Tags user @Param userUuid query int true "User ID" @Param token query string true "Verification token" @Router /user/verify/{userUuid}/{token} [get]

Jump to

Keyboard shortcuts

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