use of com.amazonaws.services.cognitoidentityprovider.model.GetUserAttributeVerificationCodeResult in project aws-sdk-android by aws-amplify.
the class CognitoUser method getAttributeVerificationCodeInBackground.
/**
* Requests code to verify a user attribute, in background.
* <p>
* The user attributes that can be verified are those attributes that can be
* used to communicate with the user, e.g. phone_number and email. The
* verification code is sent to the medium that is represented by the
* attribute. Attribute verification is required to enable the attribute to
* be used an attribute as alias for the user. Aliases attributes can be
* used in lieu of the userId to authenticate the user. If an attribute was
* used in the confirm the user after sign-up, then that alias is already
* verified and does not require re-verification.
* </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 attributeName REQUIRED: Name of the attribute that requires
* verification.
* @param callback REQUIRED: callback.
*/
public void getAttributeVerificationCodeInBackground(final Map<String, String> clientMetadata, final String attributeName, final VerificationHandler callback) {
if (callback == null) {
throw new CognitoParameterInvalidException("callback is null");
}
final CognitoUser user = this;
new Thread(new Runnable() {
@Override
public void run() {
final Handler handler = new Handler(context.getMainLooper());
Runnable returnCallback;
try {
final CognitoUserSession session = user.getCachedSession();
final GetUserAttributeVerificationCodeResult getUserAttributeVerificationCodeResult = getAttributeVerificationCodeInternal(clientMetadata, attributeName, session);
returnCallback = new Runnable() {
@Override
public void run() {
callback.onSuccess(new CognitoUserCodeDeliveryDetails(getUserAttributeVerificationCodeResult.getCodeDeliveryDetails()));
}
};
} 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.GetUserAttributeVerificationCodeResult in project aws-sdk-android by aws-amplify.
the class CognitoUser method getAttributeVerificationCode.
/**
* Requests code to verify a user attribute, in current thread.
* <p>
* The user attributes that can be verified are those attributes that can be
* used to communicate with the user, e.g. phone_number and email. The
* verification code is sent to the medium that is represented by the
* attribute. Attribute verification is required to enable the attribute to
* be used an attribute as alias for the user. Aliases attributes can be
* used in lieu of the userId to authenticate the user. If an attribute was
* used in the confirm the user after sign-up, then that alias is already
* verified and does not require re-verification. <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 attributeName REQUIRED: Name of the attribute that requires
* verification.
* @param callback REQUIRED: callback.
*/
public void getAttributeVerificationCode(final Map<String, String> clientMetadata, String attributeName, VerificationHandler callback) {
if (callback == null) {
throw new CognitoParameterInvalidException("callback is null");
}
try {
final GetUserAttributeVerificationCodeResult getUserAttributeVerificationCodeResult = getAttributeVerificationCodeInternal(clientMetadata, attributeName, this.getCachedSession());
callback.onSuccess(new CognitoUserCodeDeliveryDetails(getUserAttributeVerificationCodeResult.getCodeDeliveryDetails()));
} catch (final Exception e) {
callback.onFailure(e);
}
}
Aggregations