user

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const ENCRYPTION_TIMES = 10000

Variables

This section is empty.

Functions

func GenerateUsername

func GenerateUsername(n int) string

func GetUser

func GetUser(ctx iris.Context) (*auth.User, error)

从 ctx获取 User

func LoginRequire

func LoginRequire(ctx iris.Context)

从 ctx获取 User

func MakePassword

func MakePassword(password string) string

func Register

func Register(app *iris.Application, apiPrefix string)

func UserIDAuth

func UserIDAuth(ctx iris.Context) *auth.User

Types

type AuthController

type AuthController struct {
}

func (*AuthController) PostLoginbypwd

func (c *AuthController) PostLoginbypwd(ctx iris.Context) response.IRFResult

@Summary 根据用户手机号和密码获取 token @Tags auth @Accept json @Description ### 返回:200 @Description ``` @Description { @Description "code": 0 @Description "data": { @Description "token": "eameeljfaldkfaldkf.alkfjelfkelfe.alekfjelfjkelfjelfj" @Description }, @Description } @Description ``` @Router /auth [post]

type AuthUser

type AuthUser struct {
	ID          string                `json:"id" gorm:"primaryKey"`
	Password    string                `json:"password"`
	Username    string                `json:"username" gorm:"unique"`
	IsSuperuser bool                  `json:"is_superuser"`
	Phone       string                `json:"phone"`
	IsActive    bool                  `json:"is_active"`
	CreatedAt   datatypes.IRFTime     `json:"created_at" gorm:"autoCreateTime"`
	IsDel       soft_delete.DeletedAt `json:"is_del" gorm:"softDelete:flag"`
}

用户表 实现 auth.IUserModel

func CreateAuthUser

func CreateAuthUser(phone string, password string, isAdmin bool) (*AuthUser, error)

func GetUserModel

func GetUserModel(ctx iris.Context) (*AuthUser, error)

从 ctx获取 User

func (*AuthUser) GetByPwd

func (u *AuthUser) GetByPwd(phone string, pwd string) error

根据用户名的密码获取User对象

func (*AuthUser) GetID

func (u *AuthUser) GetID() string

实现 auth.IUserModel

func (*AuthUser) GetUsername

func (u *AuthUser) GetUsername() string

实现 auth.IUserModel

func (*AuthUser) IsAuthorized

func (u *AuthUser) IsAuthorized() bool

实现 auth.IUserModel

func (*AuthUser) Save

func (u *AuthUser) Save() error

根据用户名的密码获取User对象

type IAuthController

type IAuthController interface {
	PostLoginbypwd(ctx iris.Context) response.IRFResult // 手机密码登录
}

func NewAuthController

func NewAuthController() IAuthController

type LoginByPwdSerializer

type LoginByPwdSerializer struct {
	Phone    string `json:"phone" validate:"number,len=11"`
	Password string `json:"password" validate:"min=6,max=12"`
}

手机号登录

Jump to

Keyboard shortcuts

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