Documentation
¶
Index ¶
- Variables
- func ChangePassword(ctx context.Context, id uint, oldPassword, newPassword string) error
- func GetIdByToken(ctx context.Context, tk string) (uint, error)
- func GetOrAddToken(ctx context.Context, id uint) string
- func GetUserById(ctx context.Context, id uint) (*models.User, error)
- func Login(ctx context.Context, username, password string) (uint, error)
- func Logout(ctx context.Context, tk string) error
- func Register(ctx context.Context, username, password string) (uint, error)
- func UpsertUser(ctx context.Context, user *models.User) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( UsernamePattern = regexp.MustCompile(`^[a-zA-Z\d_-]{4,16}$`) // PasswordPattern 密码正则,最少6位,包括至少1个大写字母,1个小写字母,1个数字,1个特殊字符 PasswordPattern = regexp2.MustCompile(`^.*(?=.{6,})(?=.*\d)(?=.*[A-Z])(?=.*[a-z])(?=.*[!@#$%^&*? ]).*$`, 0) )
View Source
var ( ErrUsernameExist = errors.New("用户名被占用") ErrWrongFormat = errors.New("格式错误") ErrInvalidToken = errors.New("无效的token") )
View Source
var ErrWrongOldPassword = errors.New("旧密码错误")
Functions ¶
func ChangePassword ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.