mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-23 10:45:47 +08:00
Add restriction to built-in org and app modification.
This commit is contained in:
parent
8345295d0c
commit
f5bc76016d
@ -206,6 +206,10 @@ func UpdateApplication(id string, application *Application) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
if name == "app-built-in" {
|
||||
application.Name = name
|
||||
}
|
||||
|
||||
for _, providerItem := range application.Providers {
|
||||
providerItem.Provider = nil
|
||||
}
|
||||
@ -234,6 +238,10 @@ func AddApplication(application *Application) bool {
|
||||
}
|
||||
|
||||
func DeleteApplication(application *Application) bool {
|
||||
if application.Name == "app-built-in" {
|
||||
return false
|
||||
}
|
||||
|
||||
affected, err := adapter.Engine.ID(core.PK{application.Owner, application.Name}).Delete(&Application{})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
@ -112,6 +112,10 @@ func UpdateOrganization(id string, organization *Organization) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
if name == "built-in" {
|
||||
organization.Name = name
|
||||
}
|
||||
|
||||
if organization.MasterPassword != "" {
|
||||
credManager := cred.GetCredManager(organization.PasswordType)
|
||||
if credManager != nil {
|
||||
@ -138,6 +142,10 @@ func AddOrganization(organization *Organization) bool {
|
||||
}
|
||||
|
||||
func DeleteOrganization(organization *Organization) bool {
|
||||
if organization.Name == "built-in" {
|
||||
return false
|
||||
}
|
||||
|
||||
affected, err := adapter.Engine.ID(core.PK{organization.Owner, organization.Name}).Delete(&Organization{})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
@ -132,7 +132,7 @@ class ApplicationEditPage extends React.Component {
|
||||
{Setting.getLabel(i18next.t("general:Name"), i18next.t("general:Name - Tooltip"))} :
|
||||
</Col>
|
||||
<Col span={22} >
|
||||
<Input value={this.state.application.name} onChange={e => {
|
||||
<Input value={this.state.application.name} disabled={this.state.application.name === "app-built-in"} onChange={e => {
|
||||
this.updateApplicationField('name', e.target.value);
|
||||
}} />
|
||||
</Col>
|
||||
|
@ -236,8 +236,9 @@ class ApplicationListPage extends React.Component {
|
||||
<Popconfirm
|
||||
title={`Sure to delete application: ${record.name} ?`}
|
||||
onConfirm={() => this.deleteApplication(index)}
|
||||
disabled={record.name === "app-built-in"}
|
||||
>
|
||||
<Button style={{marginBottom: '10px'}} type="danger">{i18next.t("general:Delete")}</Button>
|
||||
<Button style={{marginBottom: '10px'}} disabled={record.name === "app-built-in"} type="danger">{i18next.t("general:Delete")}</Button>
|
||||
</Popconfirm>
|
||||
</div>
|
||||
)
|
||||
|
@ -94,7 +94,7 @@ class OrganizationEditPage extends React.Component {
|
||||
{Setting.getLabel(i18next.t("general:Name"), i18next.t("general:Name - Tooltip"))} :
|
||||
</Col>
|
||||
<Col span={22} >
|
||||
<Input value={this.state.organization.name} onChange={e => {
|
||||
<Input value={this.state.organization.name} disabled={this.state.organization.name === "built-in"} onChange={e => {
|
||||
this.updateOrganizationField('name', e.target.value);
|
||||
}} />
|
||||
</Col>
|
||||
|
@ -210,8 +210,9 @@ class OrganizationListPage extends React.Component {
|
||||
<Popconfirm
|
||||
title={`Sure to delete organization: ${record.name} ?`}
|
||||
onConfirm={() => this.deleteOrganization(index)}
|
||||
disabled={record.name === "built-in"}
|
||||
>
|
||||
<Button style={{marginBottom: '10px'}} type="danger">{i18next.t("general:Delete")}</Button>
|
||||
<Button style={{marginBottom: '10px'}} disabled={record.name === "built-in"} type="danger">{i18next.t("general:Delete")}</Button>
|
||||
</Popconfirm>
|
||||
</div>
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user