use of com.amazonaws.services.cognitoidentityprovider.model.ForgotPasswordResult in project aws-sdk-android by aws-amplify.
the class CognitoUser method forgotPasswordInBackground.
/**
* Starts the process to set a new password for forgotten password case, in
* background.
* <p>
* This will initiate the process to set a new password when the current
* password is forgotten. The new password will be successfully set only
* after the verification code, sent to the registered email or phone number
* of the user, successfully verified by Cognito Identity Provider service.
* This method will pass a continuation object to the callback. Use setters
* in the Continuation object {@link ForgotPasswordContinuation} to set the
* new password and verification code and call continue on the continuation
* object, {@code CognitoIdentityProviderContinuation.continueTask()}.
* </p>
*
* @param clientMetadata A map of custom key-value pairs that is passed to the lambda function for
* lambda functions triggered by forgot password.
* @param callback REQUIRED: {@link ForgotPasswordHandler} callback
*/
public void forgotPasswordInBackground(final Map<String, String> clientMetadata, final ForgotPasswordHandler callback) {
if (callback == null) {
throw new CognitoParameterInvalidException("callback is null");
}
final CognitoUser cognitoUser = this;
new Thread(new Runnable() {
@Override
public void run() {
final Handler handler = new Handler(context.getMainLooper());
Runnable returnCallback;
try {
final ForgotPasswordResult forgotPasswordResult = forgotPasswordInternal(clientMetadata);
final ForgotPasswordContinuation continuation = new ForgotPasswordContinuation(cognitoUser, new CognitoUserCodeDeliveryDetails(forgotPasswordResult.getCodeDeliveryDetails()), ForgotPasswordContinuation.RUN_IN_BACKGROUND, callback);
returnCallback = new Runnable() {
@Override
public void run() {
callback.getResetCode(continuation);
}
};
} catch (final Exception e) {
returnCallback = new Runnable() {
@Override
public void run() {
callback.onFailure(e);
}
};
}
handler.post(returnCallback);
}
}).start();
}
use of com.amazonaws.services.cognitoidentityprovider.model.ForgotPasswordResult in project aws-sdk-android by aws-amplify.
the class CognitoUser method forgotPassword.
/**
* Starts the process to set a new new password for forgotten password case,
* in current thread.
* <p>
* This will initiate the process to set a new password when the current
* password is forgotten. The new password will be successfully set only
* after the verification code, sent to the registered email or phone number
* of the user, successfully verified by Cognito Identity Provider service.
* This method will pass a continuation object to the callback. Use setters
* in the Continuation object {@link ForgotPasswordContinuation} to set the
* new password and verification code and call continue on the continuation
* object, {@code CognitoIdentityProviderContinuation.continueTask()}.
* <b>Note:</b> This method will perform network operations. Calling this
* method in applications' main thread will cause Android to throw
* NetworkOnMainThreadException.
* </p>
*
* @param clientMetadata A map of custom key-value pairs that is passed to the lambda function for
* lambda functions triggered by forgot password.
* @param callback REQUIRED: {@link ForgotPasswordHandler} callback
*/
public void forgotPassword(final Map<String, String> clientMetadata, final ForgotPasswordHandler callback) {
if (callback == null) {
throw new CognitoParameterInvalidException("callback is null");
}
final CognitoUser cognitoUser = this;
try {
final ForgotPasswordResult forgotPasswordResult = forgotPasswordInternal(clientMetadata);
final ForgotPasswordContinuation continuation = new ForgotPasswordContinuation(cognitoUser, new CognitoUserCodeDeliveryDetails(forgotPasswordResult.getCodeDeliveryDetails()), ForgotPasswordContinuation.RUN_IN_CURRENT, callback);
callback.getResetCode(continuation);
} catch (final Exception e) {
callback.onFailure(e);
}
}
Aggregations