Skip to content

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

Merged
one-community merged 5 commits intodevelopmentfrom
yili_fix_reset_password
Apr 13, 2025
Merged

Yili - Gives the user permission to Reset and/or Change the password of any user #2860
one-community merged 5 commits intodevelopmentfrom
yili_fix_reset_password

Conversation

@suaniii
Copy link
Contributor

@suaniii suaniii commented Nov 12, 2024

Description

Gives the user permission to Reset and:or Change the password of any user but Owner:Admin classes

Related PRS

This frontend PR is related to the backend PR #1146

How to test:

  1. check into current branch
  2. do npm install and ... to run this PR locally
  3. Clear site data/cache
  4. log as owner user
  5. go to Other Links -> Permissions Management -> Manage User Permissions -> Choose a volunteer user -> add Reset / Change Password (Others) -> click on "save changes"
  6. verify that the user who was given the permission is now able to see the reset password button and reset another volunteer user's password.(make sure to reset your own account for testing)

Screenshots or videos of changes:

0.mov

1
2
3

@netlify
Copy link

netlify bot commented Nov 12, 2024

Deploy Preview for highestgoodnetwork-dev ready!

Name Link
🔨 Latest commit c57d75b
🔍 Latest deploy log https://app.netlify.com/sites/highestgoodnetwork-dev/deploys/67f61e9882f80b0008cbac41
😎 Deploy Preview https://deploy-preview-2860--highestgoodnetwork-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

manikittu810
manikittu810 previously approved these changes Nov 15, 2024
Copy link

@manikittu810 manikittu810 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @suaniii
Everything is working as mentioned.
Thank you.
Screenshot 2024-11-14 at 6 28 01 PM
Screenshot 2024-11-14 at 6 29 33 PM

Copy link

@audreydieuanh audreydieuanh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My volunteer account was able to see the reset button after I changed the permission with my admin test account.

test17

Copy link

@anji-annavarapu anji-annavarapu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v1.mov

its working all expected.

@Hritvik111 Hritvik111 added the High Priority - Please Review First This is an important PR we'd like to get merged as soon as possible label Nov 23, 2024
Copy link
Contributor

@srikanthpusthem srikanthpusthem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image image image working as expected

Copy link
Contributor

@honglinchen0524 honglinchen0524 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! I was able to give permission and see the reset password button. Video below:

PR2860.mp4

@lycan10
Copy link

lycan10 commented Jan 24, 2025

Screenshot 2025-01-23 at 9 51 47 PM

Hi, unfortunately, I cannot find the option to reset password.

yany960
yany960 previously approved these changes Feb 6, 2025
Copy link
Contributor

@yany960 yany960 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested successfully—assigned permissions correctly enable the user to see and use the reset password button. The functionality works as expected.
WeChatc7a3af584accbc1185e7e3421fcb6c7c

Peter-Nie2003
Peter-Nie2003 previously approved these changes Feb 8, 2025
Copy link
Contributor

@Peter-Nie2003 Peter-Nie2003 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function work as expected, Well done!

Screen.Recording.2025-02-08.at.9.24.19.AM.mov

AurHubertMax
AurHubertMax previously approved these changes Feb 19, 2025
Copy link
Contributor

@AurHubertMax AurHubertMax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The permission to reset/change password of a user functions as expected. Gave permission to my volunteer 1 account to change password of any user, verified to see that the button to reset the password of my volunteer 2 account is available. Changed the account's password to a new password, and verified that the changes were in effect by logging into my volunteer 2 account with the new password.

z.PR.2860.proof.1.mp4

@HarideepValiveru
Copy link

Reviewed PR. The code looks really good and shows a lot of effort in organizing everything. It takes care of managing user profiles, teams, permissions, and other tasks well. The tabs and modals are really cool features.

karnati007
karnati007 previously approved these changes Apr 2, 2025
Copy link

@karnati007 karnati007 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested the Reset / Change Password (Others) permission in Other Links → Permissions Management → Manage User Permissions as an owner user. Added the permission to a volunteer user, saved changes, and confirmed that the user could see the reset password button and successfully reset another volunteer user's password. Also tested by resetting my own account. Cleared site data and cache before testing. Everything is working as expected.
YiliPR2
YiliPR

Copy link
Contributor

@nathanah nathanah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should consolidate update and reset password permissions.

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'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
setCanResetPassword(response.data.permissions.frontPermissions.includes('resetPassword'));
const canResetPassword = props.hasPermission('resetPassword');

hasPermission() checks both role and individual permissions. The current way only checks individual permissions. Doesn't need to be a state obj because it won't change after being set.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to use updatePassword permission instead.

</TabContent>
<div className="profileEditButtonContainer">
{canUpdatePassword && canEdit && !isUserSelf && (
{(canUpdatePassword && canEdit && !isUserSelf || canResetPassword) && (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't updatePassword already do what resetPassword should do?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, canUpdatePassword is now being used for this.

},
{
label: 'Reset / Change Password (Others)',
key: 'resetPassword',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the updatePassword permission was already mostly set up, but not included in PermissionsConst.js. Should be fixing/replacing updatePassword instead of adding a new permission of resetPassword on top of it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed resetPassword from both BE and FE, and updatePassword is doing the job now.

@suaniii suaniii requested a review from nathanah April 5, 2025 13:19
const [showToggleVisibilityModal, setShowToggleVisibilityModal] = useState(false);
const [pendingRehireableStatus, setPendingRehireableStatus] = useState(null);
const [isRehireable, setIsRehireable] = useState(null);
const [canUpdatePassword, setCanUpdatePassword] = useState(props.hasPermission('updatePassword'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const [canUpdatePassword, setCanUpdatePassword] = useState(props.hasPermission('updatePassword'));

Copy link
Contributor Author

@suaniii suaniii Apr 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this, use hasPermission() instead.

const response = await axios.get(ENDPOINTS.USER_PROFILE(userId));
const currentUserEmail = response.data.email;
dispatch(setCurrentUser({ ...props.auth.user, email: currentUserEmail }));
setCanUpdatePassword(response.data.permissions.frontPermissions.includes('updatePassword'));
Copy link
Contributor

@nathanah nathanah Apr 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
setCanUpdatePassword(response.data.permissions.frontPermissions.includes('updatePassword'));

This doesn't check role permissions.

Copy link
Contributor Author

@suaniii suaniii Apr 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this, use hasPermission() instead.

const canChangeUserStatus = props.hasPermission('changeUserStatus');
const canAddDeleteEditOwners = props.hasPermission('addDeleteEditOwners');
const canPutUserProfile = props.hasPermission('putUserProfile');
const canUpdatePassword = props.hasPermission('updatePassword');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is how it should be done. canUpdatePassword doesn't need to be a state object and should always be set to props.hasPermission('updatePassword').

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted my changes, now it's using hasPermission()

@suaniii suaniii force-pushed the yili_fix_reset_password branch from c14fba2 to 593597a Compare April 9, 2025 03:14
@suaniii suaniii requested a review from nathanah April 9, 2025 23:55
Copy link
Contributor

@nathanah nathanah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@one-community
Copy link
Member

Thank you all, merging!

@one-community one-community merged commit a62c099 into development Apr 13, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

High Priority - Please Review First This is an important PR we'd like to get merged as soon as possible

Projects

None yet

Development

Successfully merging this pull request may close these issues.