mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-05 05:50:19 +08:00
Add isSelf() in user edit page
This commit is contained in:
@ -127,8 +127,12 @@ class UserEditPage extends React.Component {
|
|||||||
this.getUser();
|
this.getUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isSelf() {
|
||||||
|
return (this.state.user.id === this.props.account?.id);
|
||||||
|
}
|
||||||
|
|
||||||
isSelfOrAdmin() {
|
isSelfOrAdmin() {
|
||||||
return (this.state.user.id === this.props.account?.id) || Setting.isAdminUser(this.props.account);
|
return this.isSelf() || Setting.isAdminUser(this.props.account);
|
||||||
}
|
}
|
||||||
|
|
||||||
renderAccountItem(accountItem) {
|
renderAccountItem(accountItem) {
|
||||||
@ -136,7 +140,6 @@ class UserEditPage extends React.Component {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const isSelf = this.state.user.id === this.props.account?.id;
|
|
||||||
const isAdmin = Setting.isAdminUser(this.props.account);
|
const isAdmin = Setting.isAdminUser(this.props.account);
|
||||||
|
|
||||||
// return (
|
// return (
|
||||||
@ -148,7 +151,7 @@ class UserEditPage extends React.Component {
|
|||||||
// )
|
// )
|
||||||
|
|
||||||
if (accountItem.viewRule === "Self") {
|
if (accountItem.viewRule === "Self") {
|
||||||
if (!isSelf && !isAdmin) {
|
if (!this.isSelfOrAdmin()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} else if (accountItem.viewRule === "Admin") {
|
} else if (accountItem.viewRule === "Admin") {
|
||||||
@ -159,7 +162,7 @@ class UserEditPage extends React.Component {
|
|||||||
|
|
||||||
let disabled = false;
|
let disabled = false;
|
||||||
if (accountItem.modifyRule === "Self") {
|
if (accountItem.modifyRule === "Self") {
|
||||||
if (!isSelf && !isAdmin) {
|
if (!this.isSelfOrAdmin()) {
|
||||||
disabled = true;
|
disabled = true;
|
||||||
}
|
}
|
||||||
} else if (accountItem.modifyRule === "Admin") {
|
} else if (accountItem.modifyRule === "Admin") {
|
||||||
@ -296,7 +299,11 @@ class UserEditPage extends React.Component {
|
|||||||
}} />
|
}} />
|
||||||
</Col>
|
</Col>
|
||||||
<Col span={11} >
|
<Col span={11} >
|
||||||
{this.state.user.id === this.props.account?.id ? (<ResetModal application={this.state.application} disabled={disabled} buttonText={i18next.t("user:Reset Email...")} destType={"email"} />) : null}
|
{
|
||||||
|
!this.isSelf() ? null : (
|
||||||
|
<ResetModal application={this.state.application} disabled={disabled} buttonText={i18next.t("user:Reset Email...")} destType={"email"} />
|
||||||
|
)
|
||||||
|
}
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
);
|
);
|
||||||
@ -556,7 +563,7 @@ class UserEditPage extends React.Component {
|
|||||||
{Setting.getLabel(i18next.t("user:WebAuthn credentials"), i18next.t("user:WebAuthn credentials"))} :
|
{Setting.getLabel(i18next.t("user:WebAuthn credentials"), i18next.t("user:WebAuthn credentials"))} :
|
||||||
</Col>
|
</Col>
|
||||||
<Col span={22} >
|
<Col span={22} >
|
||||||
<WebAuthnCredentialTable table={this.state.user.webauthnCredentials} updateTable={(table) => {this.updateUserField("webauthnCredentials", table);}} refresh={this.getUser.bind(this)} />
|
<WebAuthnCredentialTable isSelf={this.isSelf()} table={this.state.user.webauthnCredentials} updateTable={(table) => {this.updateUserField("webauthnCredentials", table);}} refresh={this.getUser.bind(this)} />
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
);
|
);
|
||||||
|
@ -44,7 +44,7 @@ class WebAuthnCredentialTable extends React.Component {
|
|||||||
title={() => (
|
title={() => (
|
||||||
<div>
|
<div>
|
||||||
{i18next.t("user:WebAuthn credentials")}
|
{i18next.t("user:WebAuthn credentials")}
|
||||||
<Button style={{marginRight: "5px"}} type="primary" size="small" onClick={() => {this.registerWebAuthn();}}>
|
<Button disabled={!this.props.isSelf} style={{marginRight: "5px"}} type="primary" size="small" onClick={() => {this.registerWebAuthn();}}>
|
||||||
{i18next.t("general:Add")}
|
{i18next.t("general:Add")}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
Reference in New Issue
Block a user