Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yili - Gives the user permission to Reset and/or Change the password of any user #2860

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/components/PermissionsManagement/PermissionsConst.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ export const permissionLabels = [
description:
'Gives the user permission to change the requirement to the user to submit a summary.',
},
{
label: 'Reset / Change Password (Others)',
key: 'resetPassword',
description:
'Gives the user permission to Reset and/or Change the password of any user but Owner/Admin classes. ',
},
{
label: 'Manage Time Off Requests',
key: 'manageTimeOffRequests',
Expand Down
4 changes: 3 additions & 1 deletion src/components/UserProfile/UserProfile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ function UserProfile(props) {
const [showConfirmDialog, setShowConfirmDialog] = useState(false);
const [pendingRehireableStatus, setPendingRehireableStatus] = useState(null);
const [isRehireable, setIsRehireable] = useState(null);
const [canResetPassword, setCanResetPassword] = useState(false);

const userProfileRef = useRef();

Expand Down Expand Up @@ -308,6 +309,7 @@ function UserProfile(props) {
const response = await axios.get(ENDPOINTS.USER_PROFILE(userId));
const currentUserEmail = response.data.email;
dispatch(setCurrentUser({ ...props.auth.user, email: currentUserEmail }));
setCanResetPassword(response.data.permissions.frontPermissions.includes('resetPassword'));
} catch (err) {
toast.error('Error while getting current logged in user email');
}
Expand Down Expand Up @@ -1289,7 +1291,7 @@ function UserProfile(props) {
</TabPane>
</TabContent>
<div className="profileEditButtonContainer">
{canUpdatePassword && canEdit && !isUserSelf && (
{(canUpdatePassword && canEdit && !isUserSelf || canResetPassword) && (
<ResetPasswordButton
className="mr-1 btn-bottom"
user={userProfile}
Expand Down
Loading