mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-04 05:10:19 +08:00
fix: error login logic of mobile phone login (#1017)
* fix: #1016 1. Limit username cannot be digital. 2. Check avoid repeat register with same phone or email. Signed-off-by: 疯魔慕薇 <kfanjian@gmail.com> * Update check.go Signed-off-by: 疯魔慕薇 <kfanjian@gmail.com> Co-authored-by: Yang Luo <hsluoyz@qq.com>
This commit is contained in:
@ -18,6 +18,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
"unicode"
|
||||||
|
|
||||||
"github.com/casdoor/casdoor/cred"
|
"github.com/casdoor/casdoor/cred"
|
||||||
"github.com/casdoor/casdoor/util"
|
"github.com/casdoor/casdoor/util"
|
||||||
@ -42,11 +43,25 @@ func CheckUserSignup(application *Application, organization *Organization, usern
|
|||||||
if application.IsSignupItemVisible("Username") {
|
if application.IsSignupItemVisible("Username") {
|
||||||
if len(username) <= 1 {
|
if len(username) <= 1 {
|
||||||
return "username must have at least 2 characters"
|
return "username must have at least 2 characters"
|
||||||
} else if reWhiteSpace.MatchString(username) {
|
}
|
||||||
|
if unicode.IsDigit(rune(username[0])) {
|
||||||
|
return "username cannot start with a digit"
|
||||||
|
}
|
||||||
|
if util.IsEmailValid(username) {
|
||||||
|
return "username cannot be an email address"
|
||||||
|
}
|
||||||
|
if reWhiteSpace.MatchString(username) {
|
||||||
return "username cannot contain white spaces"
|
return "username cannot contain white spaces"
|
||||||
} else if HasUserByField(organization.Name, "name", username) {
|
}
|
||||||
|
if HasUserByField(organization.Name, "name", username) {
|
||||||
return "username already exists"
|
return "username already exists"
|
||||||
}
|
}
|
||||||
|
if HasUserByField(organization.Name, "email", username) {
|
||||||
|
return "email already exists"
|
||||||
|
}
|
||||||
|
if HasUserByField(organization.Name, "phone", username) {
|
||||||
|
return "phone already exists"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(password) <= 5 {
|
if len(password) <= 5 {
|
||||||
|
Reference in New Issue
Block a user