service

package
v0.0.0-...-f1d22f6 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

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

func ChangePassword(ctx context.Context, id uint, oldPassword, newPassword string) error

func GetIdByToken

func GetIdByToken(ctx context.Context, tk string) (uint, error)

func GetOrAddToken

func GetOrAddToken(ctx context.Context, id uint) string

func GetUserById

func GetUserById(ctx context.Context, id uint) (*models.User, error)

func Login

func Login(ctx context.Context, username, password string) (uint, error)

func Logout

func Logout(ctx context.Context, tk string) error

func Register

func Register(ctx context.Context, username, password string) (uint, error)

func UpsertUser

func UpsertUser(ctx context.Context, user *models.User) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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