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

Passwordless | Passcodes for reset password - non-ACTIVE users #2902

Merged
merged 3 commits into from
Sep 19, 2024

Conversation

coldlink
Copy link
Member

@coldlink coldlink commented Sep 18, 2024

What does this change?

In #2852 we implemented passcodes for reset password for some "ACTIVE" users. Namely the ones with both the "password" and "email" authenticator, and users with just the "email" authenticator.

In #2889 we implemented passcode for reset password for the remaining active users, i.e the ones with only the "password" authenticator.

This PR adds the ability for all except non-existent users to reset their passcodes using passwords.

For users in a non-ACTIVE state, we should first get them into one of the ACTIVE states in order to send them an email which allows them to reset their password with a passcode.

The best way to do this is to first deactivate the user, which works on all user states and puts them into the DEPROVISIONED state.

Then we can activate the user, which will put them into the PROVISIONED state and return us a recovery token.

We then use the recovery token to set a placeholder password for the user, which transitions them into the ACTIVE state and then we can call changePasswordEmailIdx method again to send the user a passcode as they'll be in one of the ACTIVE states, namely the one with the "email" and "password" authenticator, or the one with only the "password" authenticator.

From there the existing functionality for ACTIVE users takes over and we send the users a passcode!

We also modify the validateEmailAndPasswordSetSecurely method to do the exact reverse depending on a flag. The flagStatus parameter was added in to set these flags emailValidated and passwordSetSecurely to false if flagStatus is provided as false. flagStatus defaults to true to retain existing behaviour.

A whole lotta cypress tests are included to make sure this functionality works.

Tested

  • CODE

@coldlink coldlink changed the title feat(idx): passcode password reset for non-ACTIVE users Passwordless | Passcodes for reset password - non-ACTIVE users Sep 18, 2024
@coldlink coldlink marked this pull request as ready for review September 18, 2024 14:20
@coldlink coldlink requested a review from a team as a code owner September 18, 2024 14:20
@coldlink coldlink requested review from guardian-ci and removed request for guardian-ci September 18, 2024 14:27
@coldlink coldlink requested review from guardian-ci and removed request for guardian-ci September 18, 2024 15:55
pvighi
pvighi previously approved these changes Sep 18, 2024
Copy link
Contributor

@pvighi pvighi left a comment

Choose a reason for hiding this comment

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

nice test coverage for all the cases!

@coldlink coldlink force-pushed the mm/passcodes-active-password-only branch from 234d6e2 to b63b345 Compare September 19, 2024 10:06
@coldlink coldlink requested review from a team and removed request for a team September 19, 2024 10:08
Base automatically changed from mm/passcodes-active-password-only to main September 19, 2024 10:31
@coldlink coldlink dismissed pvighi’s stale review September 19, 2024 10:31

The base branch was changed.

For users in a non-ACTIVE state, we should first get them into one of the ACTIVE states in order to send them an email which allows them to reset their password with a passcode.

The best way to do this is to first deactivate the user, which works on all user states and puts them into the DEPROVISIONED state.

Then we can activate the user, which will put them into the PROVISIONED state and return us a recovery token.

We then use the recovery token to set a placeholder password for the user, which transitions them into the ACTIVE state and then we can call `changePasswordEmailIdx` method again to send the user a passcode as they'll be in one of the ACTIVE states
@coldlink coldlink requested a review from a team September 19, 2024 10:42
pvighi
pvighi previously approved these changes Sep 19, 2024
export const validateEmailAndPasswordSetSecurely = async ({
id,
ip,
unsetFlags = false,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
unsetFlags = false,
setFlags = true,

Perhaps just default to true and avoid the negation on line 30, I find it a little bit confusing 😅

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah that's a good point! I'll see what I can conjure up.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated it to flagStatus instead, which makes more sense than "set"/"unset"!

@coldlink coldlink requested review from a team and removed request for a team September 19, 2024 11:05
@coldlink coldlink merged commit d83b0d3 into main Sep 19, 2024
20 checks passed
@coldlink coldlink deleted the mm/passcodes-non-active-reset branch September 19, 2024 12:26
@coldlink coldlink added the passwordless PRs/Issues related to passwordless/passcode functionality label Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
passwordless PRs/Issues related to passwordless/passcode functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants