Skip to content

Commit

Permalink
Hide user change password button for admins (stashapp#675)
Browse files Browse the repository at this point in the history
  • Loading branch information
InfiniteStash authored and feederbox826 committed Nov 15, 2023
1 parent ee37ad8 commit fa0d415
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions frontend/src/pages/users/User.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ const UserComponent: FC<Props> = ({ user, refetch }) => {
const [revokeInvite] = useRevokeInvite();

const showPrivate = isPrivateUser(user);
const isOwner = isPrivateUser(user) && user.id === Auth.user?.id;

const endpointURL = configData && `${configData.getConfig.host_url}/graphql`;

Expand Down Expand Up @@ -191,7 +192,7 @@ const UserComponent: FC<Props> = ({ user, refetch }) => {
<Link to={createHref(ROUTE_USER_EDITS, user)} className="ms-2">
<Button variant="secondary">User Edits</Button>
</Link>
{showPrivate && (
{isOwner && (
<Link to={ROUTE_USER_PASSWORD} className="ms-2">
<Button>Change Password</Button>
</Link>
Expand All @@ -214,7 +215,7 @@ const UserComponent: FC<Props> = ({ user, refetch }) => {
</div>
</div>
<hr />
{isPrivateUser(user) && (
{showPrivate && (
<>
<Row>
<Col xs={2}>Email</Col>
Expand Down Expand Up @@ -306,7 +307,7 @@ const UserComponent: FC<Props> = ({ user, refetch }) => {
</Table>
</Col>
</Row>
{isPrivateUser(user) && (
{showPrivate && (
<Row>
<Col xs={2}>Invite Tokens</Col>
<InputGroup className="col">
Expand All @@ -324,7 +325,7 @@ const UserComponent: FC<Props> = ({ user, refetch }) => {
</InputGroup>
</Row>
)}
{isPrivateUser(user) && user.id === Auth.user?.id && (
{isOwner && (
<Row className="my-2">
<Col xs={2}>Invite Keys</Col>
<Col>
Expand All @@ -344,18 +345,15 @@ const UserComponent: FC<Props> = ({ user, refetch }) => {
</Button>
</InputGroup>
))}
<div>
{showPrivate && (
<Button
variant="link"
onClick={() => handleGenerateCode()}
disabled={user.invite_tokens === 0}
>
<Icon icon={faPlus} className="me-2" />
Generate Key
</Button>
)}
</div>
<Button
variant="link"
onClick={() => handleGenerateCode()}
disabled={user.invite_tokens === 0}
className="d-block"
>
<Icon icon={faPlus} className="me-2" />
Generate Key
</Button>
</Col>
</Row>
)}
Expand Down

0 comments on commit fa0d415

Please sign in to comment.