Allow global admin to modify username.

This commit is contained in:
Gucheng Wang
2022-01-13 23:19:36 +08:00
parent fe48c38bc6
commit b91b4aec91
5 changed files with 15 additions and 4 deletions

View File

@ -18,6 +18,7 @@ import (
"time"
"github.com/astaxie/beego"
"github.com/casbin/casdoor/object"
"github.com/casbin/casdoor/util"
)
@ -35,6 +36,12 @@ type SessionData struct {
ExpireTime int64
}
func (c *ApiController) IsGlobalAdmin() bool {
username := c.GetSessionUsername()
user := object.GetUser(username)
return user.Owner == "built-in" || user.IsGlobalAdmin
}
// GetSessionUsername ...
func (c *ApiController) GetSessionUsername() string {
// check if user session expired