mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-23 18:54:03 +08:00
Support using "?allowEmpty=1" to bypass empty displayName check in update-user API
This commit is contained in:
parent
6700d2e244
commit
e584a6a111
@ -258,6 +258,13 @@ func (c *ApiController) UpdateUser() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if c.Input().Get("allowEmpty") == "" {
|
||||||
|
if user.DisplayName == "" {
|
||||||
|
c.ResponseError(c.T("user:Display name cannot be empty"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if msg := object.CheckUpdateUser(oldUser, &user, c.GetAcceptLanguage()); msg != "" {
|
if msg := object.CheckUpdateUser(oldUser, &user, c.GetAcceptLanguage()); msg != "" {
|
||||||
c.ResponseError(msg)
|
c.ResponseError(msg)
|
||||||
return
|
return
|
||||||
|
@ -406,10 +406,6 @@ func CheckUsername(username string, lang string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func CheckUpdateUser(oldUser, user *User, lang string) string {
|
func CheckUpdateUser(oldUser, user *User, lang string) string {
|
||||||
if user.DisplayName == "" {
|
|
||||||
return i18n.Translate(lang, "user:Display name cannot be empty")
|
|
||||||
}
|
|
||||||
|
|
||||||
if oldUser.Name != user.Name {
|
if oldUser.Name != user.Name {
|
||||||
if msg := CheckUsername(user.Name, lang); msg != "" {
|
if msg := CheckUsername(user.Name, lang); msg != "" {
|
||||||
return msg
|
return msg
|
||||||
|
Loading…
x
Reference in New Issue
Block a user