feat: use six-digit numeric member invite codes
This commit is contained in:
@@ -2,6 +2,7 @@ package sysin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
@@ -11,7 +12,7 @@ type AppMemberRegisterInp struct {
|
||||
Username string `json:"username" v:"required|length:3,64#用户名不能为空|用户名长度为3到64个字符"`
|
||||
Mobile string `json:"mobile" v:"required|phone-loose#手机号不能为空|手机号格式不正确"`
|
||||
Password string `json:"password" v:"required|length:8,64#密码不能为空|密码长度为8到64个字符"`
|
||||
InviteCode string `json:"inviteCode" v:"max-length:32#邀请码不能超过32个字符"`
|
||||
InviteCode string `json:"inviteCode" v:"required#请输入邀请码"`
|
||||
RegisterOrigin string `json:"registerOrigin" v:"max-length:512#注册来源不能超过512个字符"`
|
||||
RegisterHost string `json:"registerHost" v:"max-length:255#注册域名不能超过255个字符"`
|
||||
}
|
||||
@@ -20,6 +21,9 @@ func (in *AppMemberRegisterInp) Filter(ctx context.Context) error {
|
||||
in.Username = strings.TrimSpace(in.Username)
|
||||
in.Mobile = strings.TrimSpace(in.Mobile)
|
||||
in.InviteCode = strings.TrimSpace(in.InviteCode)
|
||||
if !regexp.MustCompile(`^[0-9]{6}$`).MatchString(in.InviteCode) {
|
||||
return gerror.New("邀请码必须为6位数字")
|
||||
}
|
||||
if !containsLetterAndNumber(in.Password) {
|
||||
return gerror.New("密码至少8位且必须同时包含字母和数字")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user