mirror of
https://github.com/casdoor/casdoor.git
synced 2025-09-09 21:22:56 +08:00
Fix bug in IsGlobalAdmin().
This commit is contained in:
@@ -15,6 +15,7 @@
|
|||||||
package controllers
|
package controllers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/astaxie/beego"
|
"github.com/astaxie/beego"
|
||||||
@@ -38,7 +39,16 @@ type SessionData struct {
|
|||||||
|
|
||||||
func (c *ApiController) IsGlobalAdmin() bool {
|
func (c *ApiController) IsGlobalAdmin() bool {
|
||||||
username := c.GetSessionUsername()
|
username := c.GetSessionUsername()
|
||||||
|
if strings.HasPrefix(username, "app/") {
|
||||||
|
// e.g., "app/app-casnode"
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
user := object.GetUser(username)
|
user := object.GetUser(username)
|
||||||
|
if user == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
return user.Owner == "built-in" || user.IsGlobalAdmin
|
return user.Owner == "built-in" || user.IsGlobalAdmin
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user