mirror of
https://github.com/casdoor/casdoor.git
synced 2025-09-09 10:02:56 +08:00
feat: en/decodeURI in permission/role name (#2137)
This commit is contained in:
@@ -112,7 +112,7 @@ func getPermission(owner string, name string) (*Permission, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetPermission(id string) (*Permission, error) {
|
func GetPermission(id string) (*Permission, error) {
|
||||||
owner, name := util.GetOwnerAndNameFromId(id)
|
owner, name := util.GetOwnerAndNameFromIdNoCheck(id)
|
||||||
return getPermission(owner, name)
|
return getPermission(owner, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,7 +149,7 @@ func UpdatePermission(id string, permission *Permission) (bool, error) {
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
owner, name := util.GetOwnerAndNameFromId(id)
|
owner, name := util.GetOwnerAndNameFromIdNoCheck(id)
|
||||||
oldPermission, err := getPermission(owner, name)
|
oldPermission, err := getPermission(owner, name)
|
||||||
if oldPermission == nil {
|
if oldPermission == nil {
|
||||||
return false, nil
|
return false, nil
|
||||||
|
@@ -82,12 +82,12 @@ func getRole(owner string, name string) (*Role, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetRole(id string) (*Role, error) {
|
func GetRole(id string) (*Role, error) {
|
||||||
owner, name := util.GetOwnerAndNameFromId(id)
|
owner, name := util.GetOwnerAndNameFromIdNoCheck(id)
|
||||||
return getRole(owner, name)
|
return getRole(owner, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
func UpdateRole(id string, role *Role) (bool, error) {
|
func UpdateRole(id string, role *Role) (bool, error) {
|
||||||
owner, name := util.GetOwnerAndNameFromId(id)
|
owner, name := util.GetOwnerAndNameFromIdNoCheck(id)
|
||||||
oldRole, err := getRole(owner, name)
|
oldRole, err := getRole(owner, name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
|
@@ -69,7 +69,7 @@ func getObject(ctx *context.Context) (string, string) {
|
|||||||
// query == "?id=built-in/admin"
|
// query == "?id=built-in/admin"
|
||||||
id := ctx.Input.Query("id")
|
id := ctx.Input.Query("id")
|
||||||
if id != "" {
|
if id != "" {
|
||||||
return util.GetOwnerAndNameFromId(id)
|
return util.GetOwnerAndNameFromIdNoCheck(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
owner := ctx.Input.Query("owner")
|
owner := ctx.Input.Query("owner")
|
||||||
|
@@ -30,7 +30,7 @@ class PermissionEditPage extends React.Component {
|
|||||||
this.state = {
|
this.state = {
|
||||||
classes: props,
|
classes: props,
|
||||||
organizationName: props.organizationName !== undefined ? props.organizationName : props.match.params.organizationName,
|
organizationName: props.organizationName !== undefined ? props.organizationName : props.match.params.organizationName,
|
||||||
permissionName: props.match.params.permissionName,
|
permissionName: decodeURIComponent(props.match.params.permissionName),
|
||||||
permission: null,
|
permission: null,
|
||||||
organizations: [],
|
organizations: [],
|
||||||
model: null,
|
model: null,
|
||||||
@@ -449,7 +449,7 @@ class PermissionEditPage extends React.Component {
|
|||||||
if (willExist) {
|
if (willExist) {
|
||||||
this.props.history.push("/permissions");
|
this.props.history.push("/permissions");
|
||||||
} else {
|
} else {
|
||||||
this.props.history.push(`/permissions/${this.state.permission.owner}/${this.state.permission.name}`);
|
this.props.history.push(`/permissions/${this.state.permission.owner}/${encodeURIComponent(this.state.permission.name)}`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Setting.showMessage("error", `${i18next.t("general:Failed to save")}: ${res.msg}`);
|
Setting.showMessage("error", `${i18next.t("general:Failed to save")}: ${res.msg}`);
|
||||||
|
@@ -128,7 +128,7 @@ class PermissionListPage extends BaseListPage {
|
|||||||
...this.getColumnSearchProps("name"),
|
...this.getColumnSearchProps("name"),
|
||||||
render: (text, record, index) => {
|
render: (text, record, index) => {
|
||||||
return (
|
return (
|
||||||
<Link to={`/permissions/${record.owner}/${text}`}>
|
<Link to={`/permissions/${record.owner}/${encodeURIComponent(text)}`}>
|
||||||
{text}
|
{text}
|
||||||
</Link>
|
</Link>
|
||||||
);
|
);
|
||||||
@@ -336,7 +336,7 @@ class PermissionListPage extends BaseListPage {
|
|||||||
render: (text, record, index) => {
|
render: (text, record, index) => {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Button style={{marginTop: "10px", marginBottom: "10px", marginRight: "10px"}} type="primary" onClick={() => this.props.history.push(`/permissions/${record.owner}/${record.name}`)}>{i18next.t("general:Edit")}</Button>
|
<Button style={{marginTop: "10px", marginBottom: "10px", marginRight: "10px"}} type="primary" onClick={() => this.props.history.push(`/permissions/${record.owner}/${encodeURIComponent(record.name)}`)}>{i18next.t("general:Edit")}</Button>
|
||||||
<PopconfirmModal
|
<PopconfirmModal
|
||||||
title={i18next.t("general:Sure to delete") + `: ${record.name} ?`}
|
title={i18next.t("general:Sure to delete") + `: ${record.name} ?`}
|
||||||
onConfirm={() => this.deletePermission(index)}
|
onConfirm={() => this.deletePermission(index)}
|
||||||
|
@@ -148,7 +148,7 @@ class PlanListPage extends BaseListPage {
|
|||||||
...this.getColumnSearchProps("role"),
|
...this.getColumnSearchProps("role"),
|
||||||
render: (text, record, index) => {
|
render: (text, record, index) => {
|
||||||
return (
|
return (
|
||||||
<Link to={`/roles/${text}`}>
|
<Link to={`/roles/${encodeURIComponent(text)}`}>
|
||||||
{text}
|
{text}
|
||||||
</Link>
|
</Link>
|
||||||
);
|
);
|
||||||
|
@@ -26,7 +26,7 @@ class RoleEditPage extends React.Component {
|
|||||||
this.state = {
|
this.state = {
|
||||||
classes: props,
|
classes: props,
|
||||||
organizationName: props.organizationName !== undefined ? props.organizationName : props.match.params.organizationName,
|
organizationName: props.organizationName !== undefined ? props.organizationName : props.match.params.organizationName,
|
||||||
roleName: props.match.params.roleName,
|
roleName: decodeURIComponent(props.match.params.roleName),
|
||||||
role: null,
|
role: null,
|
||||||
organizations: [],
|
organizations: [],
|
||||||
users: [],
|
users: [],
|
||||||
@@ -225,7 +225,7 @@ class RoleEditPage extends React.Component {
|
|||||||
if (willExist) {
|
if (willExist) {
|
||||||
this.props.history.push("/roles");
|
this.props.history.push("/roles");
|
||||||
} else {
|
} else {
|
||||||
this.props.history.push(`/roles/${this.state.role.owner}/${this.state.role.name}`);
|
this.props.history.push(`/roles/${this.state.role.owner}/${encodeURIComponent(this.state.role.name)}`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Setting.showMessage("error", `${i18next.t("general:Failed to save")}: ${res.msg}`);
|
Setting.showMessage("error", `${i18next.t("general:Failed to save")}: ${res.msg}`);
|
||||||
|
@@ -121,7 +121,7 @@ class RoleListPage extends BaseListPage {
|
|||||||
...this.getColumnSearchProps("name"),
|
...this.getColumnSearchProps("name"),
|
||||||
render: (text, record, index) => {
|
render: (text, record, index) => {
|
||||||
return (
|
return (
|
||||||
<Link to={`/roles/${record.owner}/${record.name}`}>
|
<Link to={`/roles/${record.owner}/${encodeURIComponent(record.name)}`}>
|
||||||
{text}
|
{text}
|
||||||
</Link>
|
</Link>
|
||||||
);
|
);
|
||||||
@@ -213,7 +213,7 @@ class RoleListPage extends BaseListPage {
|
|||||||
render: (text, record, index) => {
|
render: (text, record, index) => {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Button style={{marginTop: "10px", marginBottom: "10px", marginRight: "10px"}} type="primary" onClick={() => this.props.history.push(`/roles/${record.owner}/${record.name}`)}>{i18next.t("general:Edit")}</Button>
|
<Button style={{marginTop: "10px", marginBottom: "10px", marginRight: "10px"}} type="primary" onClick={() => this.props.history.push(`/roles/${record.owner}/${encodeURIComponent(record.name)}`)}>{i18next.t("general:Edit")}</Button>
|
||||||
<PopconfirmModal
|
<PopconfirmModal
|
||||||
title={i18next.t("general:Sure to delete") + `: ${record.name} ?`}
|
title={i18next.t("general:Sure to delete") + `: ${record.name} ?`}
|
||||||
onConfirm={() => this.deleteRole(index)}
|
onConfirm={() => this.deleteRole(index)}
|
||||||
|
Reference in New Issue
Block a user