mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-02 11:20:18 +08:00
Add object.IsAppUser()
This commit is contained in:
@ -405,8 +405,8 @@ func GetApplicationByUser(user *User) (*Application, error) {
|
||||
}
|
||||
|
||||
func GetApplicationByUserId(userId string) (application *Application, err error) {
|
||||
owner, name := util.GetOwnerAndNameFromId(userId)
|
||||
if owner == "app" {
|
||||
_, name := util.GetOwnerAndNameFromId(userId)
|
||||
if IsAppUser(userId) {
|
||||
application, err = getApplication("admin", name)
|
||||
return
|
||||
}
|
||||
|
@ -410,7 +410,7 @@ func CheckUserPermission(requestUserId, userId string, strict bool, lang string)
|
||||
}
|
||||
|
||||
hasPermission := false
|
||||
if strings.HasPrefix(requestUserId, "app/") {
|
||||
if IsAppUser(requestUserId) {
|
||||
hasPermission = true
|
||||
} else {
|
||||
requestUser, err := GetUser(requestUserId)
|
||||
|
@ -1003,7 +1003,7 @@ func (user *User) GetFriendlyName() string {
|
||||
}
|
||||
|
||||
func isUserIdGlobalAdmin(userId string) bool {
|
||||
return strings.HasPrefix(userId, "built-in/") || strings.HasPrefix(userId, "app/")
|
||||
return strings.HasPrefix(userId, "built-in/") || IsAppUser(userId)
|
||||
}
|
||||
|
||||
func ExtendUserWithRolesAndPermissions(user *User) (err error) {
|
||||
|
@ -464,3 +464,10 @@ func (user *User) IsAdminUser() bool {
|
||||
|
||||
return user.IsAdmin || user.IsGlobalAdmin()
|
||||
}
|
||||
|
||||
func IsAppUser(userId string) bool {
|
||||
if strings.HasPrefix(userId, "app/") {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
Reference in New Issue
Block a user