mirror of
https://github.com/casdoor/casdoor.git
synced 2025-09-09 11:52:56 +08:00
Add getBuiltInAccountItems()
This commit is contained in:
@@ -39,26 +39,8 @@ func InitDb() {
|
|||||||
initWebAuthn()
|
initWebAuthn()
|
||||||
}
|
}
|
||||||
|
|
||||||
func initBuiltInOrganization() bool {
|
func getBuiltInAccountItems() []*AccountItem {
|
||||||
organization := getOrganization("admin", "built-in")
|
return []*AccountItem{
|
||||||
if organization != nil {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
organization = &Organization{
|
|
||||||
Owner: "admin",
|
|
||||||
Name: "built-in",
|
|
||||||
CreatedTime: util.GetCurrentTime(),
|
|
||||||
DisplayName: "Built-in Organization",
|
|
||||||
WebsiteUrl: "https://example.com",
|
|
||||||
Favicon: fmt.Sprintf("%s/img/casbin/favicon.ico", conf.GetConfigString("staticBaseUrl")),
|
|
||||||
PasswordType: "plain",
|
|
||||||
CountryCodes: []string{"CN"},
|
|
||||||
DefaultAvatar: fmt.Sprintf("%s/img/casbin.svg", conf.GetConfigString("staticBaseUrl")),
|
|
||||||
Tags: []string{},
|
|
||||||
Languages: []string{"en", "zh", "es", "fr", "de", "ja", "ko", "ru", "vi"},
|
|
||||||
InitScore: 2000,
|
|
||||||
AccountItems: []*AccountItem{
|
|
||||||
{Name: "Organization", Visible: true, ViewRule: "Public", ModifyRule: "Admin"},
|
{Name: "Organization", Visible: true, ViewRule: "Public", ModifyRule: "Admin"},
|
||||||
{Name: "ID", Visible: true, ViewRule: "Public", ModifyRule: "Immutable"},
|
{Name: "ID", Visible: true, ViewRule: "Public", ModifyRule: "Immutable"},
|
||||||
{Name: "Name", Visible: true, ViewRule: "Public", ModifyRule: "Admin"},
|
{Name: "Name", Visible: true, ViewRule: "Public", ModifyRule: "Admin"},
|
||||||
@@ -87,7 +69,29 @@ func initBuiltInOrganization() bool {
|
|||||||
{Name: "Is deleted", Visible: true, ViewRule: "Admin", ModifyRule: "Admin"},
|
{Name: "Is deleted", Visible: true, ViewRule: "Admin", ModifyRule: "Admin"},
|
||||||
{Name: "WebAuthn credentials", Visible: true, ViewRule: "Self", ModifyRule: "Self"},
|
{Name: "WebAuthn credentials", Visible: true, ViewRule: "Self", ModifyRule: "Self"},
|
||||||
{Name: "Managed accounts", Visible: true, ViewRule: "Self", ModifyRule: "Self"},
|
{Name: "Managed accounts", Visible: true, ViewRule: "Self", ModifyRule: "Self"},
|
||||||
},
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func initBuiltInOrganization() bool {
|
||||||
|
organization := getOrganization("admin", "built-in")
|
||||||
|
if organization != nil {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
organization = &Organization{
|
||||||
|
Owner: "admin",
|
||||||
|
Name: "built-in",
|
||||||
|
CreatedTime: util.GetCurrentTime(),
|
||||||
|
DisplayName: "Built-in Organization",
|
||||||
|
WebsiteUrl: "https://example.com",
|
||||||
|
Favicon: fmt.Sprintf("%s/img/casbin/favicon.ico", conf.GetConfigString("staticBaseUrl")),
|
||||||
|
PasswordType: "plain",
|
||||||
|
CountryCodes: []string{"CN"},
|
||||||
|
DefaultAvatar: fmt.Sprintf("%s/img/casbin.svg", conf.GetConfigString("staticBaseUrl")),
|
||||||
|
Tags: []string{},
|
||||||
|
Languages: []string{"en", "zh", "es", "fr", "de", "ja", "ko", "ru", "vi"},
|
||||||
|
InitScore: 2000,
|
||||||
|
AccountItems: getBuiltInAccountItems(),
|
||||||
}
|
}
|
||||||
AddOrganization(organization)
|
AddOrganization(organization)
|
||||||
return false
|
return false
|
||||||
|
@@ -179,34 +179,7 @@ func initDefinedOrganization(organization *Organization) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
organization.CreatedTime = util.GetCurrentTime()
|
organization.CreatedTime = util.GetCurrentTime()
|
||||||
organization.AccountItems = []*AccountItem{
|
organization.AccountItems = getBuiltInAccountItems()
|
||||||
{Name: "Organization", Visible: true, ViewRule: "Public", ModifyRule: "Admin"},
|
|
||||||
{Name: "ID", Visible: true, ViewRule: "Public", ModifyRule: "Immutable"},
|
|
||||||
{Name: "Name", Visible: true, ViewRule: "Public", ModifyRule: "Admin"},
|
|
||||||
{Name: "Display name", Visible: true, ViewRule: "Public", ModifyRule: "Self"},
|
|
||||||
{Name: "Avatar", Visible: true, ViewRule: "Public", ModifyRule: "Self"},
|
|
||||||
{Name: "User type", Visible: true, ViewRule: "Public", ModifyRule: "Admin"},
|
|
||||||
{Name: "Password", Visible: true, ViewRule: "Self", ModifyRule: "Self"},
|
|
||||||
{Name: "Email", Visible: true, ViewRule: "Public", ModifyRule: "Self"},
|
|
||||||
{Name: "Phone", Visible: true, ViewRule: "Public", ModifyRule: "Self"},
|
|
||||||
{Name: "CountryCode", Visible: true, ViewRule: "Public", ModifyRule: "Admin"},
|
|
||||||
{Name: "Country/Region", Visible: true, ViewRule: "Public", ModifyRule: "Self"},
|
|
||||||
{Name: "Location", Visible: true, ViewRule: "Public", ModifyRule: "Self"},
|
|
||||||
{Name: "Affiliation", Visible: true, ViewRule: "Public", ModifyRule: "Self"},
|
|
||||||
{Name: "Title", Visible: true, ViewRule: "Public", ModifyRule: "Self"},
|
|
||||||
{Name: "Homepage", Visible: true, ViewRule: "Public", ModifyRule: "Self"},
|
|
||||||
{Name: "Bio", Visible: true, ViewRule: "Public", ModifyRule: "Self"},
|
|
||||||
{Name: "Tag", Visible: true, ViewRule: "Public", ModifyRule: "Admin"},
|
|
||||||
{Name: "Signup application", Visible: true, ViewRule: "Public", ModifyRule: "Admin"},
|
|
||||||
{Name: "Roles", Visible: true, ViewRule: "Public", ModifyRule: "Immutable"},
|
|
||||||
{Name: "Permissions", Visible: true, ViewRule: "Public", ModifyRule: "Immutable"},
|
|
||||||
{Name: "3rd-party logins", Visible: true, ViewRule: "Self", ModifyRule: "Self"},
|
|
||||||
{Name: "Properties", Visible: false, ViewRule: "Admin", ModifyRule: "Admin"},
|
|
||||||
{Name: "Is admin", Visible: true, ViewRule: "Admin", ModifyRule: "Admin"},
|
|
||||||
{Name: "Is global admin", Visible: true, ViewRule: "Admin", ModifyRule: "Admin"},
|
|
||||||
{Name: "Is forbidden", Visible: true, ViewRule: "Admin", ModifyRule: "Admin"},
|
|
||||||
{Name: "Is deleted", Visible: true, ViewRule: "Admin", ModifyRule: "Admin"},
|
|
||||||
}
|
|
||||||
|
|
||||||
AddOrganization(organization)
|
AddOrganization(organization)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user