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

[SDK] Allow passwords to be set at the point of reset confirmation #6171

Merged
merged 7 commits into from
Jun 7, 2022

Conversation

ouchadam
Copy link
Contributor

@ouchadam ouchadam commented May 27, 2022

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other :

Content

Fixes #6169

Updates the LoginWizard reset api to allow passing the new password at the point of confirmation

  • Removes the newPassword parameter from LoginWizard.resetPassword in favour of only supply it as part of resetPasswordMailConfirmed
  • Moves the reset password new password to the ViewModel state, emitting an error if the password has not been set
  • Also introduces a ResetState to the OnboardingViewModel in preparation for the flow changes

Motivation and context

To enable the FTUE reset password journey which involves supplying a password after the reset email has been confirmed instead of the current flow which involves passing the email and password upfront.

Screenshots / GIFs

No UI changes

Tests

No production changes

Tested devices

  • Physical
  • Emulator
  • OS version(s): 31

@ouchadam ouchadam added Z-FTUE Issue is relevant to the first time use project or experience matrix-sdk PR-Small PR with less than 20 updated lines labels May 27, 2022
@github-actions
Copy link

github-actions bot commented May 27, 2022

Unit Test Results

146 files  146 suites   2m 51s ⏱️
238 tests 238 ✔️ 0 💤 0
796 runs  796 ✔️ 0 💤 0

Results for commit edfabb0.

♻️ This comment has been updated with latest results.

Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

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

LGTM;
But having two ways to do the same thing is maybe not ideal from a SDK user POV.

Have you considered fully remove newPassword parameter in resetPassword?

I would vote to do so, no matter if there is an API break.

*/
suspend fun resetPassword(email: String,
newPassword: String)
suspend fun resetPassword(email: String, newPassword: String? = null)
Copy link
Member

Choose a reason for hiding this comment

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

When I created this API, I was following the UI, when the form was asking for the email and the new password. I have checked and it's fine to provide the Pwd later.

return when (resetPasswordData) {
null -> throw IllegalStateException("developer error, no reset password in progress")
else -> {
val password = newPassword ?: resetPasswordData.newPassword ?: throw IllegalStateException("developer error, no new password set")
Copy link
Member

Choose a reason for hiding this comment

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

Do we want to enforce that newPassword and resetPasswordData.newPassword are not not null simultaneously? Or are the same?

@@ -63,14 +63,15 @@ interface LoginWizard {
* [resetPasswordMailConfirmed] is successfully called.
*
* @param email an email previously associated to the account the user wants the password to be reset.
* @param newPassword the desired new password
* @param newPassword the desired new password, can be optionally set here or as part of [resetPasswordMailConfirmed]
Copy link
Member

Choose a reason for hiding this comment

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

Maybe add the point that if the pwd is provided here, it will be temporarily stored in the SDK encrypted DB.
To avoid that consider passing the pwd in [resetPasswordMailConfirmed]

@ouchadam
Copy link
Contributor Author

Have you considered fully remove newPassword parameter in resetPassword?

I originally had this but wasn't sure of the consequences of no longer persisting the password within the pendingState in the database

I'm happy to update and remove!

@ouchadam
Copy link
Contributor Author

will close and rework to provide a single way to reset the password

@ouchadam ouchadam closed this May 30, 2022
@ouchadam ouchadam reopened this May 30, 2022

if (safeLoginWizard == null) {
setState { copy(isLoading = false) }
Copy link
Contributor Author

@ouchadam ouchadam May 30, 2022

Choose a reason for hiding this comment

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

by making the loginWizard non null (which the compiler is warning is impossible to be null) we can simplify the branching

Copy link
Member

Choose a reason for hiding this comment

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

I have noticed this warning. I think this is relatively new, probably since a Kotlin version upgrade. I am also wondering why the compiler is not failing, since warnings are errors on our project. So looks more like a IDE inspection warning.

@ouchadam ouchadam requested review from a team, Claire1817, ariskotsomitopoulos and bmarty and removed request for a team May 30, 2022 13:17
Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

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

LGTM!

@ouchadam ouchadam mentioned this pull request May 31, 2022
6 tasks
@@ -470,7 +472,8 @@ class LoginViewModel2 @AssistedInject constructor(

currentJob = viewModelScope.launch {
try {
safeLoginWizard.resetPasswordMailConfirmed()
val state = awaitState()
safeLoginWizard.resetPasswordMailConfirmed(state.resetPasswordNewPassword!!)
Copy link
Contributor

Choose a reason for hiding this comment

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

is it possible to avoid the not-null assertion operator ?

Copy link
Contributor Author

@ouchadam ouchadam May 31, 2022

Choose a reason for hiding this comment

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

it's possible (we're avoiding it in the OnboardingViewModel) but I've taken a shortcut here in the LoginViewModel2 as this entire package will be removed once the FTUE is finished

for context, Login2 is the proof of concept which has lead to the FTUE project

I'd prefer to avoid making tooo many changes to this package, but would be happy to make the change if you feel it's worth doing 👍

@ouchadam ouchadam force-pushed the feature/adm/sdk-new-password-on-confirmation branch from 3ae103c to 2f51280 Compare June 1, 2022 16:19
@ouchadam ouchadam removed the request for review from ariskotsomitopoulos June 1, 2022 16:19
@ouchadam ouchadam force-pushed the feature/adm/sdk-new-password-on-confirmation branch from 2f51280 to edfabb0 Compare June 6, 2022 12:59
@ouchadam ouchadam requested a review from Claire1817 June 7, 2022 09:00
Copy link
Contributor

@Claire1817 Claire1817 left a comment

Choose a reason for hiding this comment

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

Tested: Ok :)

@ouchadam ouchadam merged commit 462d307 into develop Jun 7, 2022
@ouchadam ouchadam deleted the feature/adm/sdk-new-password-on-confirmation branch June 7, 2022 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
matrix-sdk PR-Small PR with less than 20 updated lines Z-FTUE Issue is relevant to the first time use project or experience
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[SDK] Allow supplying a password to the LoginWizard.resetPasswordMailConfirmation step
3 participants