@Override public void performFirebaseRegistration(Activity activity, final String email, String password) { FirebaseAuth.getInstance() .createUserWithEmailAndPassword(email, password) .addOnCompleteListener(activity, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { Log.e(TAG, "performFirebaseRegistration:onComplete:" + task.isSuccessful()); // If sign in fails, display a message to the user. If sign in succeeds // the auth state listener will be notified and logic to handle the // signed in user can be handled in the listener. if (!task.isSuccessful()) { mOnRegistrationListener.onFailure(task.getException().getMessage()); } else { // Add the user to users table. /*DatabaseReference database= FirebaseDatabase.getInstance().getReference(); User user = new User(task.getResult().getUser().getUid(), email); database.child("users").push().setValue(user);*/ mOnRegistrationListener.onSuccess(task.getResult().getUser()); } } }); }
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) { Log.d(TAG, "firebaseAuthWithGooogle:" + acct.getId()); AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null); mFirebaseAuth.signInWithCredential(credential) .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { Log.d(TAG, "signInWithCredential:onComplete:" + task.isSuccessful()); // If sign in fails, display a message to the user. If sign in succeeds // the auth state listener will be notified and logic to handle the // signed in user can be handled in the listener. if (!task.isSuccessful()) { Log.w(TAG, "signInWithCredential", task.getException()); Toast.makeText(SignInActivity.this, "Authentication failed.", Toast.LENGTH_SHORT).show(); } else { startActivity(new Intent(SignInActivity.this, MainActivity.class)); finish(); } } }); }
@Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); when(mockStorageHelpers.getApiKeyFromManifest(any(Context.class), eq(StorageHelpers .DIGITS_CONSUMER_KEY_KEY))).thenReturn(DIGITS_CONSUMER_KEY); when(mockStorageHelpers.getApiKeyFromManifest(any(Context.class), eq(StorageHelpers .DIGITS_CONSUMER_SECRET_KEY))).thenReturn(DIGITS_CONSUMER_SECRET); when(mockStorageHelpers.getApiKeyFromManifest(any(Context.class), eq(StorageHelpers .FABRIC_API_KEY_KEY))).thenReturn(FABRIC_API_KEY); authResult = new AuthResult() { @Override public FirebaseUser getUser() { return mockFirebaseUser; } @Override public AdditionalUserInfo getAdditionalUserInfo() { return null; } }; authResultTask = Tasks.forResult(authResult); }
private void signIn(String email, String password) { Log.d(TAG, "signIn:" + email); mAuth.signInWithEmailAndPassword(email, password) .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { if (task.isSuccessful()) { // Sign in success, update UI with the signed-in user's information Log.d(TAG, "signInWithEmail:success"); FirebaseUser user = mAuth.getCurrentUser(); } else { // If sign in fails, display a message to the user. Log.w(TAG, "signInWithEmail:failure", task.getException()); } } }); }
private void authWithGithub() { FirebaseAuth mAuth = FirebaseAuth.getInstance(); // [START auth_with_github] String token = "<GITHUB-ACCESS-TOKEN>"; AuthCredential credential = GithubAuthProvider.getCredential(token); mAuth.signInWithCredential(credential) .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { Log.d(TAG, "signInWithCredential:onComplete:" + task.isSuccessful()); // If sign in fails, display a message to the user. If sign in succeeds // the auth state listener will be notified and logic to handle the // signed in user can be handled in the listener. if (!task.isSuccessful()) { Log.w(TAG, "signInWithCredential", task.getException()); Toast.makeText(MainActivity.this, "Authentication failed.", Toast.LENGTH_SHORT).show(); } // ... } }); // [END auth_with_github] }
@Override public void onComplete(@NonNull Task<AuthResult> task) { if (task.isSuccessful()) { FirebaseAuth firebaseAuth = SessionManager.getFirebaseAuth(); FirebaseUser currentUser = SessionManager.getFirebaseUser(); boolean isEmailVerified = currentUser.isEmailVerified(); // TODO zmienić z powrotem if (true) { updateLoginConfigInSharedPrefs(); SessionManager.initializeCurrentUserFirebaseListeners(); SessionManager.initializeFamilyMembersFirebaseListener(); Intent intent = new Intent(context, MainActivity.class); context.startActivity(intent); } else { firebaseAuth.signOut(); Toast.makeText(context, R.string.email_not_verified, Toast.LENGTH_LONG).show(); } } else { logger.logWarn("Sign In Failure: " + task.getException()); Toast.makeText(context, R.string.invalid_email_or_password, Toast.LENGTH_LONG).show(); } }
private void firebaseAuthWithGoogle(GoogleSignInAccount account) { Log.d(TAG, "firebaseAuthWithGoogle:" + account.getId()); showProgressDialog(); AuthCredential credential = GoogleAuthProvider.getCredential(account.getIdToken(), null); mAuth.signInWithCredential(credential) .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { Log.d(TAG, "signInWithCredential:onComplete:" + task.isSuccessful()); hideProgressDialog(); // If sign in fails, display a message to the user. If sign in succeeds // the auth state listener will be notified and logic to handle the // signed in user can be handled in the listener. if (!task.isSuccessful()) { Log.w(TAG, "signInWithCredential", task.getException()); Toast.makeText(AuthActivity.this, R.string.auth_failed, Toast.LENGTH_SHORT).show(); } // ... } }); }
private void handleTwitterSession(TwitterSession session) { Utils.d("Twitter:HandleSession:" + session); AuthCredential credential = TwitterAuthProvider.getCredential( session.getAuthToken().token, session.getAuthToken().secret); mAuth.signInWithCredential(credential) .addOnCompleteListener(activity, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { if (task.isSuccessful()) { // Sign in success, update UI with the signed-in user's information Utils.d("signInWithCredential:success"); } else { // If sign in fails, display a message to the user. Utils.w("signInWithCredential:failure: " + task.getException()); } // ... } }); }
public void createAccount(final String email, final String password) { Utils.d("E&P:CreateAccount:" + email); mAuth.createUserWithEmailAndPassword(email, password) .addOnCompleteListener(activity, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { Utils.d("E&P:CreateUserWithEmail:onComplete:" + task.isSuccessful()); // If sign in fails, display a message to the user. If sign in succeeds // the auth state listener will be notified and logic to handle the // signed in user can be handled in the listener. if (!task.isSuccessful()) { Utils.d("E&P:CreateAccount:Error"); } } }); }
private void signInWithEmail(final String email, final String password) { mAuth.signInWithEmailAndPassword(email, password) .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { if (task.isSuccessful()) { // Sign in success, update UI with the signed-in user's information Log.d(TAG, "signInWithEmail:success"); FirebaseUser user = mAuth.getCurrentUser(); Toast.makeText(AccountActivity.this, "Authentication successful", Toast.LENGTH_SHORT).show(); Intent intent = new Intent(AccountActivity.this, HomeActivity.class); startActivity(intent); finish(); } else { // If sign in fails, display a message to the user. Log.w(TAG, "signInWithEmail:failure. Signing Up for new account instead.", task.getException()); Toast.makeText(AccountActivity.this, "Authentication failed.", Toast.LENGTH_SHORT).show(); } } }); }
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) { LogUtil.logDebug(TAG, "firebaseAuthWithGoogle:" + acct.getId()); showProgress(); AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null); mAuth.signInWithCredential(credential) .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { LogUtil.logDebug(TAG, "signInWithCredential:onComplete:" + task.isSuccessful()); // If sign in fails, display a message to the user. If sign in succeeds // the auth state listener will be notified and logic to handle the // signed in user can be handled in the listener. if (!task.isSuccessful()) { handleAuthError(task); } } }); }
@Before public void initValideString(){ displayName = "Musa"; fullName = "MusaRikhotso"; FirebaseApp.initializeApp(rule.getActivity()); mAuth = FirebaseAuth.getInstance(); mAuth.signInWithEmailAndPassword("testgmail.com", "password") .addOnCompleteListener(rule.getActivity(), new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { if (task.isSuccessful()) { // Sign in success, update UI with the signed-in user's information } else { // If sign in fails, display a message to the user. Log.w("login activity", "signInWithEmail:failure", task.getException()); } } }); }
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_test); FirebaseApp.initializeApp(this); FirebaseAuth.getInstance().addAuthStateListener(this); FirebaseAuth.getInstance().signInAnonymously() .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { Log.d(TAG, "signInAnonymously:onComplete:" + task.isSuccessful()); // If sign in fails, display a message to the user. If sign in succeeds // the auth state listener will be notified and logic to handle the // signed in user can be handled in the listener. if (!task.isSuccessful()) { Log.w(TAG, "signInAnonymously", task.getException()); Toast.makeText(TestActivity.this, "Authentication failed.", Toast.LENGTH_SHORT).show(); } } }); }
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) { Log.d(TAG, "firebaseAuthWithGoogle:" + acct.getId()); AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null); mAuth.signInWithCredential(credential) .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { Log.d(TAG, "signInWithCredential:onComplete:" + task.isSuccessful()); // If sign in fails, display a message to the user. If sign in succeeds // the auth state listener will be notified and logic to handle the // signed in user can be handled in the listener. if (!task.isSuccessful()) { Log.w(TAG, "signInWithCredential", task.getException()); Toast.makeText(SignInActivity.this, "Authentication failed.", Toast.LENGTH_SHORT).show(); } } }); }
@Override public void firebaseAuthWithGoogle(final GoogleSignInAccount account) { final AuthCredential credential = GoogleAuthProvider.getCredential(account.getIdToken(), null); mAuth.signInWithCredential(credential) .addOnCompleteListener(mContext, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { mLoginView.dismissProgress(); if (!task.isSuccessful()) { mLoginView.showErrorMessage("Error In Create User"); } else { FirebaseAuth.getInstance().getCurrentUser().linkWithCredential(credential); String uid = task.getResult().getUser().getUid(); String name = account.getDisplayName(); String email = account.getEmail(); String imageProfileUrl = getHighQualityImage(account.getPhotoUrl()); createUserInFirebaseHelper(uid, new User(name, email, imageProfileUrl)); mLoginView.showMain(); } } }); }
@Override public Completable createAccount(final Credentials cred) { return Completable.create(new CompletableOnSubscribe() { @Override public void subscribe(final CompletableEmitter e) throws Exception { if (auth == null) { auth = FirebaseAuth.getInstance(); } auth.createUserWithEmailAndPassword(cred.getEmail(), cred.getPassword()) .addOnCompleteListener(new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { if (task.isSuccessful()) { e.onComplete(); } else { e.onError(task.getException()); } } }); } }); }
@Override public Completable attemptLogin(final Credentials cred) { return Completable.create(new CompletableOnSubscribe() { @Override public void subscribe(final CompletableEmitter e) throws Exception { if (auth == null) { auth = FirebaseAuth.getInstance(); } auth.signInWithEmailAndPassword(cred.getEmail(), cred.getPassword()) .addOnCompleteListener(new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { if (task.isSuccessful()) { e.onComplete(); } else { e.onError(task.getException()); } } }); } }); }
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) { Log.d(TAG, "firebaseAuthWithGoogle:" + acct.getId()); AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null); mAuth.signInWithCredential(credential) .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { Log.d(TAG, "signInWithCredential:onComplete:" + task.isSuccessful()); // If sign in fails, display a message to the user. If sign in succeeds // the auth state listener will be notified and logic to handle the // signed in user can be handled in the listener. if (!task.isSuccessful()) { Log.w(TAG, "signInWithCredential", task.getException()); Toast.makeText(Authentication.this, "Authentication failed.", Toast.LENGTH_SHORT).show(); } // ... } }); }
private void handleFacebookAccessToken(AccessToken token) { Log.d(TAG, "handleFacebookAccessToken:" + token); AuthCredential credential = FacebookAuthProvider.getCredential(token.getToken()); mAuth.signInWithCredential(credential) .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { Log.d(TAG, "signInWithCredential:onComplete:" + task.isSuccessful()); // If sign in fails, display a message to the user. If sign in succeeds // the auth state listener will be notified and logic to handle the // signed in user can be handled in the listener. if (!task.isSuccessful()) { Log.w(TAG, "signInWithCredential", task.getException()); Toast.makeText(MainActivity.this, "Authentication failed.", Toast.LENGTH_SHORT).show(); } } }); }
@Override public void onClick(View v) { int id = v.getId(); switch (id) { case R.id.explore_button: mAuth.signInAnonymously().addOnSuccessListener(new OnSuccessListener<AuthResult>() { @Override public void onSuccess(AuthResult authResult) { Intent feedsIntent = new Intent(WelcomeActivity.this, FeedsActivity.class); startActivity(feedsIntent); } }).addOnFailureListener( new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { Toast.makeText(WelcomeActivity.this, "Unable to sign in anonymously.", Toast.LENGTH_SHORT).show(); Log.e(TAG, e.getMessage()); } }); break; case R.id.sign_in_button: Intent signInIntent = new Intent(this, ProfileActivity.class); startActivity(signInIntent); break; } }
@Override public final void signIn(final String email, final String password, final Callback callback) { signInCallback = callback; // TODO: 23-Feb-17 validate email, pass; firebaseAuthManager.signInWithEmailAndPassword(email, password, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { final Exception exception = task.getException(); printStackTrace(exception); if (signInCallback != null) { signInCallback.onComplete(task.isSuccessful(), exception != null ? exception.getMessage() : ""); } } }); }
@Override public void firebaseAuthWithGoogle(GoogleSignInAccount acct,final OnLoginFinishedListener listener) { AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null); mAuth.signInWithCredential(credential) .addOnCompleteListener(new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { // If sign in fails, display a message to the user. If sign in succeeds // the auth state listener will be notified and logic to handle the // signed in user can be handled in the listener. if (!task.isSuccessful()) { listener.onLoginGoogleFail(); } } }); }
public void signIn(View view){ String email = emailEdt.getText().toString(); String password = passwordEdt.getText().toString(); mAuth.signInWithEmailAndPassword(email, password) .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { Log.d(TAG, "signInWithEmail:onComplete:" + task.isSuccessful()); // If sign in fails, display a message to the user. If sign in succeeds // the auth state listener will be notified and logic to handle the // signed in user can be handled in the listener. if (!task.isSuccessful()) { Log.w(TAG, "signInWithEmail:failed", task.getException()); Toast.makeText(startPage.this, "Authentication Failed", Toast.LENGTH_SHORT).show(); } // ... } }); }
private void handleFacebookAccessToken(AccessToken token) { Log.d(TAG, "handleFacebookAccessToken:" + token); AuthCredential credential = FacebookAuthProvider.getCredential(token.getToken()); mAuth.signInWithCredential(credential) .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { if (task.isSuccessful()) { // Sign in success, update UI with the signed-in user's information Log.d(TAG, "signInWithCredential:success"); updateUI(mAuth.getCurrentUser()); } else { // If sign in fails, display a message to the user. Log.w(TAG, "signInWithCredential:failure", task.getException()); Toast.makeText(LoginActivity.this, "Authentication failed.", Toast.LENGTH_SHORT).show(); } } }); }
@Override public void firebaseAuthWithGoogle(GoogleSignInAccount account, final Callbacks.IResultCallback<Usuario> callback) { showLog("firebaseAuthWithGoogle: " + account.getId()); AuthCredential credential = GoogleAuthProvider.getCredential(account.getIdToken(), null); FirebaseAuth.getInstance() .signInWithCredential(credential) .addOnFailureListener( reportError(callback)) .addOnSuccessListener(new OnSuccessListener<AuthResult>() { @Override public void onSuccess(AuthResult authResult) { FirebaseUser user = authResult.getUser(); loginFlow( user, callback); } }); }
public void signIn(String email, String password) { mAuth.signInWithEmailAndPassword(email, password) .addOnCompleteListener(new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { if (task.isSuccessful()) { // Sign in success, update UI with the signed-in user's information Log.d(TAG, "signInWithEmail:success"); mCurrentUser = mAuth.getCurrentUser(); } else { // If sign in fails, display a message to the user. Log.w(TAG, "signInWithEmail:failure", task.getException()); mCurrentUser = null; } } }); }
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) { MyLg.d(TAG, "firebaseAuthWithGoogle:" + acct.getId()+" "+acct.getPhotoUrl()); showProgressDialog(); AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null); mAuth.signInWithCredential(credential) .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { MyLg.d(TAG, "signInWithCredential:onComplete:" + task.isSuccessful()); // If sign in fails, display a message to the user. If sign in succeeds // the auth state listener will be notified and logic to handle the // signed in user can be handled in the listener. if (!task.isSuccessful()) { MyLg.w(TAG, "signInWithCredential"); Toas.show(context, "Authentication failed."); } hideProgressDialog(); } }); }
/** * Method signIn * * Allows a registered user to sign in. * * @param email mail address used for his account * @param password password to access his account */ private void signIn(String email, String password) { mFirebaseAuth.signInWithEmailAndPassword(email, password) .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { Log.d(TAG, "signInWithEmail:onComplete:" + task.isSuccessful()); // If sign in fails, display a message to the user. If sign in succeeds // the auth state listener will be notified and logic to handle the // signed in user can be handled in the listener. if (!task.isSuccessful()) { Log.w(TAG, "signInWithEmail", task.getException()); Toast.makeText(LoginActivity.this, "Authentication failed.", Toast.LENGTH_SHORT).show(); } else { startActivity(new Intent(LoginActivity.this, HomeActivity.class)); finish(); } } }); }
private void authenticate(String email, String password) { final FirebaseAuth mAuth = FirebaseAuth.getInstance(); mAuth.signInWithEmailAndPassword(email, password) .addOnCompleteListener(new OnCompleteListener<AuthResult>(){ @Override public void onComplete(Task<AuthResult> task) { if (task.isSuccessful()) { fetchRemoteConfig(); loadPreviousStatuses(); } else { Log.i("not sign", "authenticate: " + task.getException().getMessage().toString()); Toast.makeText(TrackerService.this, R.string.auth_failed, Toast.LENGTH_SHORT).show(); stopSelf(); } } }); }
private void handleFacebookAccessToken(AccessToken token) { LogUtil.logDebug(TAG, "handleFacebookAccessToken:" + token); showProgress(); AuthCredential credential = FacebookAuthProvider.getCredential(token.getToken()); mAuth.signInWithCredential(credential) .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { LogUtil.logDebug(TAG, "signInWithCredential:onComplete:" + task.isSuccessful()); // If sign in fails, display a message to the user. If sign in succeeds // the auth state listener will be notified and logic to handle the // signed in user can be handled in the listener. if (!task.isSuccessful()) { handleAuthError(task); } } }); }
private void createAccount() { progressBar.setVisibility(View.VISIBLE); mAuth.createUserWithEmailAndPassword(email, password) .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { Log.d(TAG, "createUserWithEmail:onComplete:" + task.isSuccessful()); isRegistrationClicked = true; // If sign in fails, display a message to the user. If sign in succeeds // the auth state listener will be notified and logic to handle the // signed in user can be handled in the listener. if (!task.isSuccessful()) { Toast.makeText(newUser.this, R.string.auth_failed, Toast.LENGTH_SHORT).show(); setViews(true); isRegistrationClicked = false; progressBar.setVisibility(View.GONE); } // ... } }); }
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) { Log.d(TAG, "firebaseAuthWithGoogle:" + acct.getId()); AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null); mAuth.signInWithCredential(credential) .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { Log.d(TAG, "signInWithCredential:onComplete:" + task.isSuccessful()); // If sign in fails, display a message to the user. If sign in succeeds // the auth state listener will be notified and logic to handle the // signed in user can be handled in the listener. if (!task.isSuccessful()) { Log.w(TAG, "signInWithCredential", task.getException()); Toast.makeText(MainActivity.this, "Authentication failed.", Toast.LENGTH_SHORT).show(); } // ... } }); }
@Override public void attemptLogin(Credentials credentials, final AuthCallback<Void> authCallback) { mFirebaseAuth.signInWithEmailAndPassword( credentials.getEmail(), credentials.getPassword() ).addOnCompleteListener(new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { if (task.isSuccessful()) { authCallback.onSuccess(null); } else { authCallback.onFailure(task.getException()); } } }); }
private void link() { if (phoneNumberCheck() == true) { mAuth.getCurrentUser().linkWithCredential(credent) .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { if (task.isSuccessful()) { Log.d(TAG, "linkWithCredential:success"); Toast.makeText(ChangePhoneNumberActivity.this, "변경되었습니다", Toast.LENGTH_SHORT).show(); IntentBack(); } else { Log.w(TAG, "linkWithCredential:failure", task.getException()); Toast.makeText(ChangePhoneNumberActivity.this, "Authentication failed.", Toast.LENGTH_SHORT).show(); } // ... } }); } else { Toast.makeText(ChangePhoneNumberActivity.this, "이미 등록되어있는 번호입니다.", Toast.LENGTH_SHORT).show(); } }
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) { Log.d(TAG, "firebaseAuthWithGoogle:" + acct.getId()); AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null); mAuth.signInWithCredential(credential) .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { if (task.isSuccessful()) { // Sign in success, update UI with the signed-in user's information Log.d(TAG, "signInWithCredential:success"); FirebaseUser user = mAuth.getCurrentUser(); printLog(TAG, "current user :" + user.getDisplayName()); updateUser(user); updateUi(); } else { // If sign in fails, display a message to the user. Log.w(TAG, "signInWithCredential:failure", task.getException()); Toast.makeText(RegisterActivity.this, "Authentication failed.", Toast.LENGTH_SHORT).show(); } // ... } }); }
private void logInToFirebaseWithGoogleSignIn(GoogleSignInAccount googleSignInAccount) { Log.v(CRDAuthActivity.class.getName(), "logInToFirebaseWithGoogleSignIn() called with: " + "googleSignInAccount = [" + googleSignInAccount + "]"); // TODO VOLKO MAKE USER WAIT AuthCredential credential = GoogleAuthProvider.getCredential(googleSignInAccount.getIdToken(), null); FirebaseAuth.getInstance() .signInWithCredential(credential) .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { Log.v(CRDAuthActivity.class.getName(), "logInToFirebaseWithGoogleSignIn.onComplete() called with: " + "isSuccessful = [" + task.isSuccessful() + "]"); // TODO VOLKO MAKE USER DE-WAIT // If sign in succeeds the auth state listener will be notified and logic to handle the signed in user can be handled in the listener. if (!task.isSuccessful()) { onFirebaseConnectionFailed(); } } }); }
public void createAccount(String email, String password){ mAuth.createUserWithEmailAndPassword(email, password) .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { Log.d(TAG, "createUserWithEmail:onComplete:" + task.isSuccessful()); // If sign in fails, display a message to the user. If sign in succeeds // the auth state listener will be notified and logic to handle the // signed in user can be handled in the listener. if (!task.isSuccessful()) { Toast.makeText(MainActivity.this, R.string.auth_failed, Toast.LENGTH_SHORT).show(); }else{ Toast.makeText(MainActivity.this, "success", Toast.LENGTH_SHORT).show(); } // ... } }); }
@Override public void onComplete(@NonNull Task<AuthResult> task) { String tagText; if (linkToExisting) { tagText = "linkWithCredential"; } else { tagText = "signInWithCredential"; } Log.d(TAG, tagText + ":onComplete:" + task.isSuccessful()); if (task.isSuccessful()) { Log.d(TAG, tagText + ":success"); useSocialNetwork(socialNetworkKey); } else { Log.d(TAG, tagText + ":failure"); } }
@Override public void signUp(final String email, final String password) { FirebaseAuth.getInstance().createUserWithEmailAndPassword(email, password) .addOnSuccessListener(new OnSuccessListener<AuthResult>() { @Override public void onSuccess(AuthResult authResult) { post(LoginEvent.onSignUpSuccess); signIn(email, password); } }) .addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { post(LoginEvent.onSignUpError, e.getMessage()); } }); }