use of com.firebase.ui.auth.ui.TaskFailureLogger in project FirebaseUI-Android by firebase.
the class WelcomeBackPasswordPrompt method next.
private void next(final String email, final String password) {
// Check for null or empty password
if (TextUtils.isEmpty(password)) {
mPasswordLayout.setError(getString(R.string.required_field));
return;
} else {
mPasswordLayout.setError(null);
}
mActivityHelper.showLoadingDialog(R.string.progress_dialog_signing_in);
final FirebaseAuth firebaseAuth = mActivityHelper.getFirebaseAuth();
// Sign in with known email and the password provided
firebaseAuth.signInWithEmailAndPassword(email, password).addOnFailureListener(new TaskFailureLogger(TAG, "Error signing in with email and password")).addOnSuccessListener(new OnSuccessListener<AuthResult>() {
@Override
public void onSuccess(AuthResult authResult) {
AuthCredential authCredential = AuthCredentialHelper.getAuthCredential(mIdpResponse);
// Otherwise, the user has an email account that we need to link to an idp.
if (authCredential == null) {
mActivityHelper.saveCredentialsOrFinish(mSaveSmartLock, authResult.getUser(), password, new IdpResponse(EmailAuthProvider.PROVIDER_ID, email));
} else {
authResult.getUser().linkWithCredential(authCredential).addOnFailureListener(new TaskFailureLogger(TAG, "Error signing in with credential " + authCredential.getProvider())).addOnSuccessListener(new OnSuccessListener<AuthResult>() {
@Override
public void onSuccess(AuthResult authResult) {
mActivityHelper.saveCredentialsOrFinish(mSaveSmartLock, authResult.getUser(), mIdpResponse);
}
});
}
}
}).addOnFailureListener(this, new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
mActivityHelper.dismissDialog();
String error = e.getLocalizedMessage();
mPasswordLayout.setError(error);
}
});
}
use of com.firebase.ui.auth.ui.TaskFailureLogger in project FirebaseUI-Android by firebase.
the class RecoverPasswordActivity method next.
private void next(final String email) {
mActivityHelper.getFirebaseAuth().sendPasswordResetEmail(email).addOnFailureListener(new TaskFailureLogger(TAG, "Error sending password reset email")).addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
mActivityHelper.dismissDialog();
RecoveryEmailSentDialog.show(email, getSupportFragmentManager());
}
}).addOnFailureListener(this, new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
mActivityHelper.dismissDialog();
if (e instanceof FirebaseAuthInvalidUserException) {
// No FirebaseUser exists with this email address, show error.
mEmailEditText.setError(getString(R.string.error_email_does_not_exist));
}
}
});
}
Aggregations