-
Notifications
You must be signed in to change notification settings - Fork 126
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
Reset password for native auth #1950
Conversation
msal/src/main/java/com/microsoft/identity/client/internal/CommandParametersAdapter.java
Outdated
Show resolved
Hide resolved
This PR includes the work for self service password reset related features of Native Auth. No new dependencies have been added as part of this PR. A technical overview of Native Auth is available at https://dev.azure.com/IdentityDivision/DevEx/_git/AuthLibrariesApiReview?path=/%5BAndroid%5D%20Native%20authentication/technical_overview.md&version=GBsammy/native-authentication&_a=preview A companion PR in MSAL is AzureAD/microsoft-authentication-library-for-android#1950
@@ -151,4 +152,23 @@ interface INativeAuthPublicClientApplication : IPublicClientApplication { | |||
* @throws MsalClientException if an account is already signed in. | |||
*/ | |||
fun signUpUsingPassword(username: String, password: CharArray, attributes: UserAttributes? = null, callback: NativeAuthPublicClientApplication.SignUpUsingPasswordCallback) | |||
|
|||
/** | |||
* Reset password for the account starting from a username; Kotlin coroutines variant. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do we mean by "starting from"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We start the reset password flow with username. Some flows like signup or signin can be started either with username only or with username and password.
* | ||
* @param error [com.microsoft.identity.client.statemachine.Error] | ||
*/ | ||
class UnexpectedError(override val error: com.microsoft.identity.client.statemachine.Error) : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the only error expected for a reset password operation is an Unexpected error? (I don't see any other error results here)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there no expected errors?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a ErrorResult class in the base class Result
to denote expected errors.
|
||
/** | ||
* UserNotFound ErrorResult, which indicates there was no account found with the provided email. | ||
* The flow should be restarted. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the account will be found upon restart of the flow?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its possible the user started this flow with incorrect email address and thats why they got the UserNotFound error. Once the flow is restarted with correct email address then it will be found.
* @param sentTo the email/phone number the code was sent to. | ||
* @param channel channel(email/phone) the code was sent through. | ||
*/ | ||
class Success( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So you can only get success in this operation? (I don't see any other result types here)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other result types in the base class Result
.
sealed interface ResetPasswordSubmitPasswordResult : Result { | ||
/** | ||
* InvalidPassword ErrorResult, which indicates the new password provided by the user is not acceptable to the server. | ||
* The password should be re-submitted. | ||
* | ||
* @param error [com.microsoft.identity.client.statemachine.InvalidPasswordError] | ||
*/ | ||
class InvalidPassword( | ||
override val error: InvalidPasswordError | ||
) : ResetPasswordSubmitPasswordResult, Result.ErrorResult(error = error) | ||
/** | ||
* PasswordResetFailed ErrorResult, which indicates the password reset flow failed. | ||
* | ||
* @param error [com.microsoft.identity.client.statemachine.GeneralError] | ||
*/ | ||
class PasswordResetFailed( | ||
override val error: GeneralError | ||
) : ResetPasswordSubmitPasswordResult, Result.ErrorResult(error = error) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about success result? also what about unexpected failures?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The success and error result are in the base class Result
. The ResetPasswordSubmitPasswordResult
has wrapped classes only for the reset password submit API specific cases.
* Submits a new password to the server; callback variant. | ||
* | ||
* @param password The password to submit. | ||
* @param callback [com.microsoft.identity.client.statemachine.states.ResetPasswordPasswordRequiredState.SubmitPasswordCallback] to receive the result on. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this going to link to the SubmitPasswordCallback file from within the Javadoc? Generally the @link
is used to create these links
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this will work. Kotlin allows linking with square brackets. https://kotlinlang.org/docs/kotlin-doc.html#inline-markup
This PR is to merge the SignIn, SIgnup and SSPR code into dev branch. This code was previously reviewed in #1897, #1919, #1949 and #1950 . A technical overview of Native Auth is available at https://dev.azure.com/IdentityDivision/DevEx/_git/AuthLibrariesApiReview?path=/%5BAndroid%5D%20Native%20authentication/technical_overview.md&version=GBsammy/native-authentication&_a=preview A companion PR in common repo is AzureAD/microsoft-authentication-library-common-for-android#2233 --------- Co-authored-by: melissaahn <[email protected]> Co-authored-by: iamgusain <[email protected]> Co-authored-by: Dome Pongmongkol <[email protected]> Co-authored-by: Sowmya Malayanur <[email protected]> Co-authored-by: Mohit <[email protected]> Co-authored-by: tanmaymanolkar1 <[email protected]> Co-authored-by: amoyixi <[email protected]> Co-authored-by: yixilin <[email protected]> Co-authored-by: fadidurah <[email protected]> Co-authored-by: Dean Xu <[email protected]> Co-authored-by: Neha Goel <[email protected]> Co-authored-by: Dome Pongmongkol <[email protected]> Co-authored-by: pedro romero vargas <[email protected]>
This PR includes the work for self service password reset related features of Native Auth. No new dependencies have been added as part of this PR.
A technical overview of Native Auth is available at https://dev.azure.com/IdentityDivision/DevEx/_git/AuthLibrariesApiReview?path=/%5BAndroid%5D%20Native%20authentication/technical_overview.md&version=GBsammy/native-authentication&_a=preview
A companion PR in MSAL is AzureAD/microsoft-authentication-library-common-for-android#2230