fix
This commit is contained in:
parent
cc1b2a657b
commit
62222bb781
|
@ -6,6 +6,7 @@ import (
|
|||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
"fusenapi/utils/chinese_to_pinyin"
|
||||
"fusenapi/utils/email"
|
||||
"fusenapi/utils/ldap_lib"
|
||||
"strings"
|
||||
|
||||
|
@ -46,8 +47,8 @@ func (l *CreateLdapUserLogic) CreateLdapUser(req *types.CreateLdapUserReq, useri
|
|||
if req.Password == "" {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "密码不能为空")
|
||||
}
|
||||
if req.Email == "" {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "邮箱不能为空")
|
||||
if !email.IsEmailValid(req.Email) {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "邮箱格式不正确")
|
||||
}
|
||||
ldapServer := ldap_lib.NewLdap(l.svcCtx.Ldap, l.svcCtx.Config.Ldap.BaseDN, l.svcCtx.Config.Ldap.RootDN)
|
||||
//把用户名转pinyin
|
||||
|
|
15
utils/email/verify.go
Normal file
15
utils/email/verify.go
Normal file
|
@ -0,0 +1,15 @@
|
|||
package email
|
||||
|
||||
import "regexp"
|
||||
|
||||
// 验证是否邮箱
|
||||
func IsEmailValid(email string) bool {
|
||||
// 邮箱正则表达式
|
||||
regex := `^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$`
|
||||
|
||||
// 编译正则表达式
|
||||
regexPattern := regexp.MustCompile(regex)
|
||||
|
||||
// 根据正则表达式验证邮箱
|
||||
return regexPattern.MatchString(email)
|
||||
}
|
Loading…
Reference in New Issue
Block a user