feat: fix bug that the default permission prevents admin to login in (#907)

* fix:The certs page is displayed incorrectly

* Translations for each language are added

* Replace the variables certificat with Certificat with certificate and Certificate

* Replace the variables certificat with Certificat with certificate and Certificate

* Variable names are more accurate

* Variable names are more accurate

* Modify the variable name

* fix: Default action prevents admin to login in
This commit is contained in:
SLingyu 2022-07-24 23:36:55 +08:00 committed by GitHub
parent 8e98fc5a9f
commit 4e3eedf246
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 1 deletions

View File

@ -236,7 +236,7 @@ func CheckAccessPermission(userId string, application *Application) (bool, error
allowed := true
var err error
for _, permission := range permissions {
if !permission.IsEnabled {
if !permission.IsEnabled || len(permission.Users) == 0 {
continue
}

View File

@ -25,6 +25,7 @@ import (
func InitDb() {
existed := initBuiltInOrganization()
if !existed {
initBuiltInPermission()
initBuiltInProvider()
initBuiltInUser()
initBuiltInApplication()
@ -230,3 +231,25 @@ func initBuiltInProvider() {
func initWebAuthn() {
gob.Register(webauthn.SessionData{})
}
func initBuiltInPermission() {
permission := GetPermission("built-in/permission-built-in")
if permission != nil {
return
}
permission = &Permission{
Owner: "built-in",
Name: "permission-built-in",
CreatedTime: util.GetCurrentTime(),
DisplayName: "Built-in Permission",
Users: []string{"built-in/admin"},
Roles: []string{},
ResourceType: "Application",
Resources: []string{"app-built-in"},
Actions: []string{"Read", "Write", "Admin"},
Effect: "Allow",
IsEnabled: true,
}
AddPermission(permission)
}