mirror of
https://github.com/casdoor/casdoor.git
synced 2025-09-10 02:32:56 +08:00
feat: fix function CheckAccountItemModifyRule (#1789)
* feat: fix function CheckAccountItemModifyRule * fix: admin changes its own username * fix: current user changes its own username * Update user.go --------- Co-authored-by: hsluoyz <hsluoyz@qq.com>
This commit is contained in:
@@ -48,6 +48,9 @@ func (c *ApiController) IsGlobalAdmin() bool {
|
|||||||
|
|
||||||
func (c *ApiController) IsAdmin() bool {
|
func (c *ApiController) IsAdmin() bool {
|
||||||
isGlobalAdmin, user := c.isGlobalAdmin()
|
isGlobalAdmin, user := c.isGlobalAdmin()
|
||||||
|
if user == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
return isGlobalAdmin || user.IsAdmin
|
return isGlobalAdmin || user.IsAdmin
|
||||||
}
|
}
|
||||||
|
@@ -216,7 +216,7 @@ func CheckAccountItemModifyRule(accountItem *AccountItem, isAdmin bool, lang str
|
|||||||
|
|
||||||
switch accountItem.ModifyRule {
|
switch accountItem.ModifyRule {
|
||||||
case "Admin":
|
case "Admin":
|
||||||
if isAdmin {
|
if !isAdmin {
|
||||||
return false, fmt.Sprintf(i18n.Translate(lang, "organization:Only admin can modify the %s."), accountItem.Name)
|
return false, fmt.Sprintf(i18n.Translate(lang, "organization:Only admin can modify the %s."), accountItem.Name)
|
||||||
}
|
}
|
||||||
case "Immutable":
|
case "Immutable":
|
||||||
|
Reference in New Issue
Block a user