Documentation
¶
Index ¶
- Constants
- func GenerateUsername(n int) string
- func GetUser(ctx iris.Context) (*auth.User, error)
- func LoginRequire(ctx iris.Context)
- func MakePassword(password string) string
- func Register(app *iris.Application, apiPrefix string)
- func UserAuth(ctx iris.Context) *auth.User
- type AuthUser
- type IUserController
- type LoginByPwdSerializer
- type UserController
Constants ¶
View Source
const ENCRYPTION_TIMES = 10000
Variables ¶
This section is empty.
Functions ¶
func GenerateUsername ¶
func MakePassword ¶
func Register ¶
func Register(app *iris.Application, apiPrefix string)
Types ¶
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 ¶
type IUserController ¶ added in v0.1.9
type IUserController interface {
PostLoginbypwd(ctx iris.Context) response.IRFResult // 手机密码登录
Get(ctx iris.Context) response.IRFResult // 获取登录用户的信息
GetBy(ctx iris.Context, id string) response.IRFResult // 根据用户id获取用户信息
}
func NewUserController ¶ added in v0.1.9
func NewUserController() IUserController
type LoginByPwdSerializer ¶
type LoginByPwdSerializer struct {
Phone string `json:"phone" validate:"number,len=11"`
Password string `json:"password" validate:"min=6,max=12"`
}
手机号登录
type UserController ¶ added in v0.1.9
type UserController struct {
}
func (*UserController) BeforeActivation ¶ added in v0.1.9
func (c *UserController) BeforeActivation(b mvc.BeforeActivation)
添加 LoginRequire 中间件
func (*UserController) Get ¶ added in v0.1.9
func (c *UserController) Get(ctx iris.Context) response.IRFResult
@Summary 根据用户id获取用户信息 @Tags auth @Accept json @Description ### 返回:200 @Router /user [get]
func (*UserController) PostLoginbypwd ¶ added in v0.1.9
func (c *UserController) PostLoginbypwd(ctx iris.Context) response.IRFResult
@Summary 根据用户手机号和密码获取 token @Tags user @Accept json @Description ### 返回:200 @Description ``` @Description { @Description "code": 0 @Description "data": { @Description "token": "eameeljfaldkfaldkf.alkfjelfkelfe.alekfjelfjkelfjelfj" @Description }, @Description } @Description ``` @Router /user [post]
Click to show internal directories.
Click to hide internal directories.