Fix bug in IsGlobalAdmin().

This commit is contained in:
Gucheng Wang 2022-01-15 23:23:14 +08:00
parent cee2c608a2
commit 030c1caa50

View File

@ -15,6 +15,7 @@
package controllers
import (
"strings"
"time"
"github.com/astaxie/beego"
@ -38,7 +39,16 @@ type SessionData struct {
func (c *ApiController) IsGlobalAdmin() bool {
username := c.GetSessionUsername()
if strings.HasPrefix(username, "app/") {
// e.g., "app/app-casnode"
return true
}
user := object.GetUser(username)
if user == nil {
return false
}
return user.Owner == "built-in" || user.IsGlobalAdmin
}