user

package
v0.0.0-...-b608779 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrIncorrectEmailOrPassword = errors.New("Incorrect Email or Password!")
	ErrEmailIsNotVerifiedYet    = errors.New("Your email is not verified yet.")
	ErrLoginsNotOpenedYet       = errors.New("Email is verified, you will be allowed to login once the contest starts.")
)
View Source
var IdentityKey = "email"

Functions

func GenerateEmailVerificationToken

func GenerateEmailVerificationToken(email string) (string, error)

func GenerateRenewPasswordToken

func GenerateRenewPasswordToken(email string) (string, error)

func GetAuthMiddleware

func GetAuthMiddleware() (*jwt.GinJWTMiddleware, error)

func ValidateEmailVerificationToken

func ValidateEmailVerificationToken(token string) (string, error)

func ValidateRenewPasswordToken

func ValidateRenewPasswordToken(token string) (string, error)

Types

type CreateUserParams

type CreateUserParams struct {
	Email    string `json:"email" binding:"required,email,max=200"`
	TeamName string `json:"team_name" binding:"required,min=3,max=60"`
	Password string `json:"password" binding:"required,min=6,max=100"`
}

type CreateUserResponse

type CreateUserResponse struct {
	UserID uint `json:"user_id"`
}

type LoginParams

type LoginParams struct {
	Email    string `form:"email" json:"email" binding:"required"`
	Password string `form:"password" json:"password" binding:"required"`
}

type RenewPasswordParams

type RenewPasswordParams struct {
	Token    string `json:"token" binding:"required"`
	Password string `json:"password" binding:"required,min=6,max=100"`
}

type ResendVerificationEmailParams

type ResendVerificationEmailParams struct {
	Email string `json:"email" binding:"required,email"`
}

type RetrieveUserResponse

type RetrieveUserResponse struct {
	Email    string `json:"email"`
	TeamName string `json:"team_name"`
}

type SendRenewPasswordEmailParams

type SendRenewPasswordEmailParams struct {
	Email string `json:"email" binding:"required,email"`
}

type User

type User struct {
	gorm.Model
	Email              string
	TeamName           string
	Password           string
	VerificationToken  string
	RenewPasswordToken string
	IsVerified         bool
}

func GetUserFromGinContext

func GetUserFromGinContext(c *gin.Context) (User, error)

func (*User) CheckPassword

func (u *User) CheckPassword(password string) error

type UserController

type UserController struct{}

func (*UserController) CreateUser

func (uc *UserController) CreateUser(c *gin.Context, params CreateUserParams) (int, interface{})

func (*UserController) RenewPassword

func (uc *UserController) RenewPassword(c *gin.Context, params RenewPasswordParams) (int, interface{})

func (*UserController) ResendVerificationEmail

func (uc *UserController) ResendVerificationEmail(c *gin.Context, params ResendVerificationEmailParams) (int, interface{})

func (*UserController) RetrieveUser

func (uc *UserController) RetrieveUser(c *gin.Context) (int, interface{})

func (*UserController) SendRenewPasswordEmail

func (uc *UserController) SendRenewPasswordEmail(c *gin.Context, params SendRenewPasswordEmailParams) (int, interface{})

func (*UserController) VerificateUser

func (uc *UserController) VerificateUser(c *gin.Context, params VerificateUserParams) (int, interface{})

type UserRouter

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

func (*UserRouter) CreateUser

func (r *UserRouter) CreateUser(c *gin.Context)

func (*UserRouter) RenewPassword

func (r *UserRouter) RenewPassword(c *gin.Context)

func (*UserRouter) ResendVerificationEmail

func (r *UserRouter) ResendVerificationEmail(c *gin.Context)

func (*UserRouter) RetrieveUser

func (r *UserRouter) RetrieveUser(c *gin.Context)

func (*UserRouter) SendRenewPasswordEmail

func (r *UserRouter) SendRenewPasswordEmail(c *gin.Context)

func (*UserRouter) VerificateUser

func (r *UserRouter) VerificateUser(c *gin.Context)

type UserStore

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

func NewUserStore

func NewUserStore() UserStore

func (*UserStore) Count

func (s *UserStore) Count(cond map[string]interface{}) (uint, error)

func (*UserStore) Create

func (s *UserStore) Create(usr User) (User, error)

func (*UserStore) Find

func (s *UserStore) Find() ([]User, error)

func (*UserStore) First

func (s *UserStore) First(cond map[string]interface{}) (User, error)

func (*UserStore) Update

func (s *UserStore) Update(userID uint, fields map[string]interface{}) error

type VerificateUserParams

type VerificateUserParams struct {
	Token string `form:"token" binding:"required"`
}

type VerificateUserResponse

type VerificateUserResponse struct {
	Email    string `json:"email"`
	Verified bool   `json:"verified"`
}

Jump to

Keyboard shortcuts

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