mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-05 05:50:19 +08:00
Add check for submitPermissionEdit()
This commit is contained in:
@ -370,6 +370,27 @@ class PermissionEditPage extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
submitPermissionEdit(willExist) {
|
submitPermissionEdit(willExist) {
|
||||||
|
if (this.state.permission.users.length === 0 && this.state.permission.roles.length === 0) {
|
||||||
|
Setting.showMessage("error", "The users and roles cannot be empty at the same time");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this.state.permission.domains.length === 0) {
|
||||||
|
Setting.showMessage("error", "The domains cannot be empty");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this.state.permission.resources.length === 0) {
|
||||||
|
Setting.showMessage("error", "The resources cannot be empty");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this.state.permission.actions.length === 0) {
|
||||||
|
Setting.showMessage("error", "The actions cannot be empty");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!Setting.isLocalAdminUser(this.props.account) && this.state.permission.submitter !== this.props.account.name) {
|
||||||
|
Setting.showMessage("error", "A normal user can only modify the permission submitted by itself");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const permission = Setting.deepCopy(this.state.permission);
|
const permission = Setting.deepCopy(this.state.permission);
|
||||||
PermissionBackend.updatePermission(this.state.organizationName, this.state.permissionName, permission)
|
PermissionBackend.updatePermission(this.state.organizationName, this.state.permissionName, permission)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
|
@ -215,6 +215,45 @@ class PermissionListPage extends BaseListPage {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: i18next.t("permission:Submitter"),
|
||||||
|
dataIndex: "submitter",
|
||||||
|
key: "submitter",
|
||||||
|
filterMultiple: false,
|
||||||
|
width: "120px",
|
||||||
|
sorter: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: i18next.t("permission:Approver"),
|
||||||
|
dataIndex: "approver",
|
||||||
|
key: "approver",
|
||||||
|
filterMultiple: false,
|
||||||
|
width: "120px",
|
||||||
|
sorter: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: i18next.t("permission:Approve time"),
|
||||||
|
dataIndex: "approveTime",
|
||||||
|
key: "approveTime",
|
||||||
|
filterMultiple: false,
|
||||||
|
width: "120px",
|
||||||
|
sorter: true,
|
||||||
|
render: (text, record, index) => {
|
||||||
|
return Setting.getFormattedDate(text);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: i18next.t("permission:State"),
|
||||||
|
dataIndex: "state",
|
||||||
|
key: "state",
|
||||||
|
filterMultiple: false,
|
||||||
|
filters: [
|
||||||
|
{text: "Approved", value: "Approved"},
|
||||||
|
{text: "Pending", value: "Pending"},
|
||||||
|
],
|
||||||
|
width: "120px",
|
||||||
|
sorter: true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: i18next.t("general:Action"),
|
title: i18next.t("general:Action"),
|
||||||
dataIndex: "",
|
dataIndex: "",
|
||||||
@ -269,7 +308,7 @@ class PermissionListPage extends BaseListPage {
|
|||||||
}
|
}
|
||||||
this.setState({loading: true});
|
this.setState({loading: true});
|
||||||
|
|
||||||
const getPermissions = Setting.isAdminUser(this.props.account) ? PermissionBackend.getPermissions : PermissionBackend.getPermissionsBySubmitter;
|
const getPermissions = Setting.isLocalAdminUser(this.props.account) ? PermissionBackend.getPermissions : PermissionBackend.getPermissionsBySubmitter;
|
||||||
getPermissions("", params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
|
getPermissions("", params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (res.status === "ok") {
|
if (res.status === "ok") {
|
||||||
|
Reference in New Issue
Block a user