auth

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EmailFound

func EmailFound(email string) bool

EmailFound to check email address already use or not

func InsertUser

func InsertUser(payload *migrations.Users) error

InsertUser to create a new user

func Login

func Login(c *gin.Context)

Login POST /authentication/login

func Logout

func Logout(c *gin.Context)

Logout PUT /authentication/logout

func MyProfile

func MyProfile(c *gin.Context)

MyProfile GET /auth/me

Get information account

func Register

func Register(c *gin.Context)

Register POST /authentication/register

This function used for register user with default roles, this is just an example. You can adjust to your needs.

func RequestResetPassword

func RequestResetPassword(c *gin.Context)

RequestResetPassword POST /authentication/request/reset-password

Request to reset password account

func ResetPassword

func ResetPassword(c *gin.Context)

ResetPassword POST /authentication/reset-password

Reset password after receive the security code to reset a password

func UpdateAccessToken

func UpdateAccessToken(c *gin.Context)

UpdateAccessToken GET /renew/access-token

Renew the access token

func UpdateUserPassword

func UpdateUserPassword(email, password string) error

UpdateUserPassword to updating a user data

func UsernameFound

func UsernameFound(username string) bool

UsernameFound to check username already use or not

Types

type EmailRequestResetPassword

type EmailRequestResetPassword struct {
	SecretCode string
}

EmailRequestResetPassword model reference to send email request reset password

type PayloadLogin

type PayloadLogin struct {
	Username string `form:"username" json:"username" binding:"required"`
	Password string `form:"password" json:"password" binding:"required"`
}

PayloadLogin model references to request /authentication/login

type PayloadRegister

type PayloadRegister struct {
	Email    string `form:"email" json:"email" binding:"required"`
	Username string `form:"username" json:"username" binding:"required"`
	Password string `form:"password" json:"password" binding:"required"`
	Fullname string `form:"fullname" json:"fullname" binding:"required"`
	Role     string `form:"role" json:"role" binding:"required"`
}

PayloadRegister model references to request /authentication/register

type PayloadRequestResetPassword

type PayloadRequestResetPassword struct {
	Email string `form:"email" json:"email" binding:"required"`
}

PayloadRequestResetPassword model references to request /authentication/request/reset-password

type PayloadResetPassword

type PayloadResetPassword struct {
	SecureCode string `form:"secure_code" json:"secure_code" binding:"required"`
	Password   string `form:"password" json:"password" binding:"required"`
}

PayloadResetPassword model reference to request /authentication/reset-password

type ResetPasswordStruct

type ResetPasswordStruct struct {
	UUID  string `json:"uuid,omitempty"`
	Email string `json:"email,omitempty"`
	Code  string `json:"code,omitempty"`
}

ResetPasswordStruct reference to JSON structure for Redis cache. The unique code only be used for 30 minutes

type Users

type Users struct {
	migrations.Users
	Write  bool `pg:"-" json:"write,omitempty"`
	Delete bool `pg:"-" json:"delete,omitempty"`
}

Users reference to table users

func GetUser

func GetUser(val, by string) (u Users, e error)

GetUser to get user data by username or uuid, only used for authentication. Don't use this query as responses for clients

Jump to

Keyboard shortcuts

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