Created
February 20, 2019 10:56
-
-
Save UtkuGlsvn/4cbc15fff75d8112d439a20092bb7e9b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Login (e mail, password): | |
Java | |
auth.signInWithEmailAndPassword(email, password) | |
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() { | |
@Override | |
public void onComplete(@NonNull Task<AuthResult> task) { | |
if (!task.isSuccessful()) { | |
// there was an error | |
if (password.length() < 6) { | |
Toast.makeText(getBaseContext(), "The password should be 6 characters at least!", Toast.LENGTH_SHORT).show(); | |
} else { | |
internetControl(); | |
Toast.makeText(getBaseContext(), "no membership found...", Toast.LENGTH_SHORT).show(); | |
} | |
dialog.dismiss(); | |
} else { | |
FirebaseUser user = auth.getCurrentUser(); | |
updateUI(user); | |
Intent intent = new Intent(Login.this, MainActivity.class); | |
startActivity(intent); | |
finish(); | |
dialog.dismiss(); | |
Toast.makeText(getBaseContext(), "Successful Login", Toast.LENGTH_SHORT).show(); | |
} | |
} | |
}); | |
Depencies: | |
implementation 'com.google.firebase:firebase-auth:16.0.3' | |
Login Token: | |
@Override | |
protected void onStart() { | |
super.onStart(); | |
FirebaseUser currentUser = auth.getCurrentUser(); | |
updateUI(currentUser); | |
} | |
FirebaseUser user = auth.getCurrentUser(); | |
updateUI(user); | |
private void updateUI(FirebaseUser user) { | |
if (user != null) { | |
startActivity(new Intent(Login.this,MainActivity.class)); | |
finish(); | |
} else { | |
Toast.makeText(Login.this,"hata",Toast.LENGTH_SHORT).show(); | |
} | |
} | |
Exit: | |
mauth.signOut(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment