feat: fix bug in GetAllowedApplications()

This commit is contained in:
Yang Luo 2023-11-08 10:31:24 +08:00
parent 498cd02d49
commit a9e72ac3cb
2 changed files with 3 additions and 4 deletions

View File

@ -346,7 +346,7 @@ func GetMaskedApplications(applications []*Application, userId string) []*Applic
}
func GetAllowedApplications(applications []*Application, userId string) ([]*Application, error) {
if isUserIdGlobalAdmin(userId) {
if userId == "" || isUserIdGlobalAdmin(userId) {
return applications, nil
}
@ -354,8 +354,7 @@ func GetAllowedApplications(applications []*Application, userId string) ([]*Appl
if err != nil {
return nil, err
}
if user.IsAdmin {
if user != nil && user.IsAdmin {
return applications, nil
}

View File

@ -851,7 +851,7 @@ func (user *User) GetId() string {
}
func isUserIdGlobalAdmin(userId string) bool {
return strings.HasPrefix(userId, "built-in/")
return strings.HasPrefix(userId, "built-in/") || strings.HasPrefix(userId, "app/")
}
func ExtendUserWithRolesAndPermissions(user *User) (err error) {