MCPcopy Create free account
hub / github.com/dearcode/candy / CheckUserName

Function CheckUserName

client/util.go:92–103  ·  view source on GitHub ↗

CheckUserName - 用户名校验, 用户名目前只支持邮箱, 长度至少6位

(name string)

Source from the content-addressed store, hash-verified

90
91// CheckUserName - 用户名校验, 用户名目前只支持邮箱, 长度至少6位
92func CheckUserName(name string) (int32, error) {
93 if len(name) < minUsernameLen {
94 return util.ErrorUserNameLen, fmt.Errorf("UserName minimum length is %v", minUsernameLen)
95 }
96
97 reg := regexp.MustCompile(`^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$`)
98 if !reg.MatchString(name) {
99 return util.ErrorUserNameFormat, fmt.Errorf("UserName format error, just support email address")
100 }
101
102 return util.ErrorOK, nil
103}
104
105// CheckUserPassword - 用户密码校验, 密码强度暂时不限制, 当前只限制密码最小长度
106func CheckUserPassword(passwd string) (int32, error) {

Callers 5

RegisterMethod · 0.85
LoginMethod · 0.85
UpdateUserInfoMethod · 0.85
UpdateUserPasswordMethod · 0.85
getUserInfoByNameMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected