I am trying to authenticate users with email and password through firebase. But it shows can not resolve updateUI(user).
Here's this part of the code.
public void OnContinue(View view) {
if(hasClickedCountinueOnce){
EditText emailTextBox = (EditText)findViewById(R.id.email);
String user = userNAAME.getText().toString();
String passwordText = password.getText().toString();
String email = emailTextBox.getText().toString();
//todo manage new account here
if(!user.isEmpty() && !passwordText.isEmpty() ){
mAuth.createUserWithEmailAndPassword(email, passwordText)
.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("SignInFailed", "createUserWithEmail:success");
FirebaseUser user = mAuth.getCurrentUser();
updateUI(user);
} else {
// If sign in fails, display a message to the user.
Log.w("SignInFailed", "createUserWithEmail:failure", task.getException());
Toast.makeText(SignUP.this, "Authentication failed.",
Toast.LENGTH_SHORT).show();
updateUI(null);
}
}
});
}
}
}
The code is from the Firebase Quickstart-Android project. This is what it does. You can implement something similar:
private void updateUI(FirebaseUser user) {
hideProgressDialog();
if (user != null) {
mStatusTextView.setText(getString(R.string.google_status_fmt, user.getEmail()));
mDetailTextView.setText(getString(R.string.firebase_status_fmt, user.getUid()));
findViewById(R.id.sign_in_button).setVisibility(View.GONE);
findViewById(R.id.sign_out_and_disconnect).setVisibility(View.VISIBLE);
} else {
mStatusTextView.setText(R.string.signed_out);
mDetailTextView.setText(null);
findViewById(R.id.sign_in_button).setVisibility(View.VISIBLE);
findViewById(R.id.sign_out_and_disconnect).setVisibility(View.GONE);
}
}
If I am getting your problem rightly with the limited code that u shared above, the function call "updateUI" refred here (https://firebase.google.com/docs/auth/android/password-auth) is the call/function you have to write on your own to update ur UI elements, and as #BobSnyder mentioned here's the link to a reference code (https://github.com/firebase/quickstart-android/blob/master/auth/app/src/main/java/com/google/firebase/quickstart/auth/EmailPasswordActivity.java#L209)
You need to write your own custom UpdateUI method in your MainActivity and write the code for what your app should do when a user is logged in with a condition for example if(user!=null).
Your coding for authentication is working.
What is the purpose of FirebaseUser user = mAuth.getCurrentUser(); inside successful login ?
To get current user, you have to implement Auth Change Listner after success login as,
private FirebaseAuth.AuthStateListener mAuthListener;
mAuthListener = new FirebaseAuth.AuthStateListener() {
#Override
public void onAuthStateChanged(#NonNull FirebaseAuth firebaseAuth) {
FirebaseUser user = firebaseAuth.getCurrentUser();
if(user !=null){
updateUI(user);
}
}
};
mAuth.addAuthStateListener(mAuthListener);
(Use different variable name)
private void updateUI(#Nullable GoogleSignInAccount account) {
if (account != null) {
mStatusTextView.setText(getString(R.string.signed_in_fmt, account.getDisplayName()));
findViewById(R.id.sign_in_button).setVisibility(View.GONE);
findViewById(R.id.sign_out_and_disconnect).setVisibility(View.VISIBLE);
} else {
mStatusTextView.setText(R.string.signed_out);
findViewById(R.id.sign_in_button).setVisibility(View.VISIBLE);
findViewById(R.id.sign_out_and_disconnect).setVisibility(View.GONE);
}
}
Related
I am using Firebase auth (email and password), and a Firebase database.
I am trying to write to the database upon successful registration.
I am using the simple database writing query, as provided by the Firebase assistant:
// Write a message to the database
FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference myRef = database.getReference("message");
myRef.setValue("Hello, World!");
It does work if I write it simply under the onCreate method of the activity, but when I write it inside the Auth success listener, the account does register, but the message is not written to the database:
// [START sign_in_with_email]
mAuth.signInWithEmailAndPassword(email, password)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
#Override
public void onComplete(#NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
// Write a message to the database
FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference myRef = database.getReference("message");
myRef.setValue("Hello, World!");
FirebaseUser user = mAuth.getCurrentUser();
updateUI(user);
//rest of code
}
There are certain steps to Use firebase database in android.
Enable the Email id and password Authentication in Firebase Console
Register the Email and Password From Code
with the help of
firebaseAuth.createUserWithEmailAndPassword(txt_email, txt_password)
.addOnCompleteListener(new OnCompleteListener<AuthResult>() {
#Override
public void onComplete(#NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
FirebaseUser firebaseUser = firebaseAuth.getCurrentUser();
assert firebaseUser != null;
String UserId = firebaseUser.getUid();
}
Use Hashmap to set Value.
And Sign In using this code
private void login(String txt_email, String txt_password) {
firebaseAuth.signInWithEmailAndPassword(txt_email,txt_password)
.addOnCompleteListener(new OnCompleteListener<AuthResult>() {
#Override
public void onComplete(#NonNull Task<AuthResult> task) {
if(task.isSuccessful()){
Intent intent = new Intent(SignIn.this,MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
hideProgressDialog();
startActivity(intent);
finish();
}
else{
String error = Objects.requireNonNull(task.getException()).getMessage();
hideProgressDialog();
Toast.makeText(SignIn.this, error, Toast.LENGTH_SHORT).show();
// Toast.makeText(SignIn.this, "Authentication Failed", Toast.LENGTH_SHORT).show();
}
}
});
}
public void showProgressDialog() {
if (mProgressDialog == null) {
mProgressDialog = new ProgressDialog(this);
mProgressDialog.setMessage(getString(R.string.loading));
mProgressDialog.setIndeterminate(true);
mProgressDialog.setCancelable(false);
}
mProgressDialog.show();
}
public void hideProgressDialog() {
if (mProgressDialog != null && mProgressDialog.isShowing()) {
mProgressDialog.dismiss();
}
}
If u have further doubt. please let me know
It seems that your firebase rules allow write when you are not authenticated
Step 1: Go to https://console.firebase.google.com/project/[projectname]/database/[projectname]/rules
Step 2: Allow access to the database by pasting the following code
{
"rules": {
".read": true,
".write": true
}
}
Step 3: Publish
The code makes your database public, its not advisable to leave it so and you should secure it once you are done testing and development.
I have created an app with the database maintaining in Firebase. I have completed the user registration part and here is the coding I used,
if(edtUsrNameS.length() >0 && edtPassS.length() >0 &&edtEmailS.length() >0) {
strUsrS = edtUsrNameS.getText().toString().trim();
strPassS = edtPassS.getText().toString().trim();
strEmailS = edtEmailS.getText().toString().trim();
if(Constant.isValidEmail(strEmailS)){
edtEmailS.setError(null);
Map<String, String> parameters = new HashMap<>();
parameters.put(Constant.TAG_USER, strUsrS.trim());
parameters.put(Constant.TAG_PASS, strPassS.trim());
parameters.put(Constant.TAG_EMAIL, strEmailS.trim());
String pushId = mFirebaseInstance.getReference(Constant.FIREBASE_LOGIN).getRef().push().getKey();
parameters.put(Constant.TAG_KEY, pushId.trim());
mFirebaseInstance.getReference(Constant.FIREBASE_LOGIN).getRef().child(strUsrS.trim()).setValue(parameters);
Toast.makeText(Login_Reg_Activity.this, "Registered Successfully", Toast.LENGTH_SHORT).show();
finish();
Intent inMain = new Intent(Login_Reg_Activity.this, Login_Reg_Activity.class);
startActivity(inMain);
}else{
edtEmailS.setError("Enter a valid Email");
}
}else{
Toast.makeText(Login_Reg_Activity.this, "Fill all detail", Toast.LENGTH_SHORT).show();
}
After the successful registration, the data are stored in the users table in Firebase like this:
My doubt is that how to login using the credential username and mobile. I have tried by the reference link, but I couldn't succeeded. So, my kind request is to direct me to do this. Also, how to restrict the duplication on user registration?
Thanks in advance.
Step 1:
make sure you have enabled the password login in firebase console as shwon below in the picture
Use Below Code For Login with email and Pwd
FirebaseAuth mAuth = FirebaseAuth.getInstance(); // same auth as you used for regestration process
mAuth.signInWithEmailAndPassword("abc#abc.com","pwd")
.addOnCompleteListener(new OnCompleteListener<AuthResult>() {
#Override
public void onComplete(#NonNull Task<AuthResult> task) {
if(task.isSuccessful()){
}
}})
.addOnFailureListener(new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception e) {
Toast.makeText(LoginActivity.this, e.getLocalizedMessage(), Toast.LENGTH_SHORT).show();
}
});
when you get successfully login than auth change listner will be invoke
Auth Change Listner
private FirebaseAuth.AuthStateListener mAuthListener;
mAuthListener = new FirebaseAuth.AuthStateListener() {
#Override
public void onAuthStateChanged(#NonNull FirebaseAuth firebaseAuth) {
FirebaseUser user = firebaseAuth.getCurrentUser();
if(user !=null){
}
}
};
mAuth.addAuthStateListener(mAuthListener);
With my current login activity, I can log in just fine, however I need to get Uid throughout my project.
This is my current login activity:
//authenticate user
firebaseAuth.signInWithEmailAndPassword(email, password)
.addOnCompleteListener(LoginActivity.this, 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.
progressbar.setVisibility(View.GONE);
if (!task.isSuccessful()) {
// there was an error
if (password.length() < 6) {
lPass.setError(getString(R.string.minimum_password));
} else {
Toast.makeText(LoginActivity.this, getString(R.string.auth_failed), Toast.LENGTH_LONG).show();
}
} else {
Intent intent = new Intent(LoginActivity.this, MapsActivity.class);
startActivity(intent);
finish();
}
}
});
}
});
How do I get the user Uid from the login and have it be accessible to all my other activities?
Thanks
You can get user info from the FirebaseUser object. In order to achieve this, please use the following code:
FirebaseAuth auth = FirebaseAuth.getInstance();
FirebaseAuth.AuthStateListener authListener = new FirebaseAuth.AuthStateListener() {
#Override
public void onAuthStateChanged(#NonNull FirebaseAuth firebaseAuth) {
FirebaseUser firebaseUser = firebaseAuth.getCurrentUser();
if (firebaseUser != null) {
String userId = firebaseUser.getUid();
String userEmail = firebaseUser.getEmail();
}
}
};
FirebaseAuth.getInstance().getCurrentUser().getUid();
This line will give you the user ID.
This is a way to get all details available for user logged in from firebase.
FirebaseAuth mFirebaseAuth = FirebaseAuth.getInstance();
FirebaseUser mFirebaseUser = mFirebaseAuth.getCurrentUser();
// User Name
mFirebaseUser.getDisplayName();
// User ID
mFirebaseUser.getUid();
// Email-ID
mFirebaseUser.getEmail();
// User-Profile (if available)
mFirebaseUser.getPhotoUrl();
Using FirebaseAuth you can get user uid,
FirebaseAuth firebaseAuth = FirebaseAuth.getInstance();
FirebaseUser firebaseUser = firebaseAuth.getCurrentUser();
Log.d(TAG," UserId : "+firebaseUser.getUid()+" , DisplayName"+firebaseUser.getDisplayName());
I have an application with two different types of users one as Teacher and the Second a normal user. if a normal member logs in, he will go to normal_memberActivity and if he's a Teacher member, he'll go to Teacher_memberActivity. How do I do this in loginActivity?
My Firebase structure:
this is database firebase rules
{
"rules": {
".read": true,
".write":true}
}
i have been solving this problem for a week. I'm sorry to say the solution proposed above is kinda misleading. Thus, i have a better solution for this, and its 101% workable !
First, this is my real-time database in Firebase:
I created a child "type" for each type of users created.
Then, i set seller's account as 1 and buyer's account as 2 inside the "type" child's value.
Second, after i successfully verified the login details. At that particular moment, i use the firebase real-time datasnapshot to pull the type value based on the current user's UID, then i verified whether is the value is equal to 1 or 2. Finally i able to start the activity based on the type of user.
Account Create code:
private void registerUser() {
progressDialog = new ProgressDialog(this);
String email = editTextEmail.getText().toString().trim();
String password = editTextPassword.getText().toString().trim();
if (TextUtils.isEmpty(email)) {
Toast.makeText(this, "Please Enter Emailsss", Toast.LENGTH_SHORT).show();
return;
}
if (TextUtils.isEmpty(password)) {
Toast.makeText(this, "Please Enter Your PASSWORDS", Toast.LENGTH_SHORT).show();
return;
}
progressDialog.setMessage("Registering User Statement..");
progressDialog.show();
//Firebase authentication (account save)
firebaseAuth.createUserWithEmailAndPassword(email, password)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
#Override
public void onComplete(#NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
//user already logged in
//start the activity
finish();
onAuthSuccess(task.getResult().getUser());
// startActivity(new Intent(getApplicationContext(), MainActivity.class));
} else {
Toast.makeText(signupActivity.this, "Could not registered , bullcraps", Toast.LENGTH_SHORT).show();
}
progressDialog.dismiss();
}
});
}
private void onAuthSuccess(FirebaseUser user) {
//String username = usernameFromEmail(user.getEmail());
// Write new user
writeNewUser(user.getUid(), toggle_val, user.getEmail());
// Go to MainActivity
startActivity(new Intent(signupActivity.this, MainActivity.class));
finish();
}
private void writeNewUser(String userId, int type, String email) {
User user = new User(Integer.toString(type), email);
if (type == 1){
mDatabase.child("users").child(userId).setValue(user);
}
else {
mDatabase.child("users").child(userId).setValue(user);
}
}
if (toggleBut.isChecked()){
toggle_val = 2;
//Toast.makeText(signupActivity.this, "You're Buyer", Toast.LENGTH_SHORT).show();
}
else{
toggle_val = 1;
//Toast.makeText(signupActivity.this, "You're Seller", Toast.LENGTH_SHORT).show();
}
Sign in Account code:
private void userLogin () {
String email = editTextEmail.getText().toString().trim();
String password = editTextPassword.getText().toString().trim();
if(TextUtils.isEmpty(email)){
Toast.makeText(this, "Please Enter Emailsss", Toast.LENGTH_SHORT).show();
return;
}
if(TextUtils.isEmpty(password)){
Toast.makeText(this, "Please Enter Your PASSWORDS", Toast.LENGTH_SHORT).show();
return;
}
progressDialog.setMessage("Login....");
progressDialog.show();
firebaseAuth.signInWithEmailAndPassword(email,password)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
#Override
public void onComplete(#NonNull Task<AuthResult> task) {
progressDialog.dismiss();
if(task.isSuccessful()){
onAuthSuccess(task.getResult().getUser());
//Toast.makeText(signinActivity.this, "Successfully Signed In", Toast.LENGTH_SHORT).show();
}
else {
Toast.makeText(signinActivity.this, "Could not login, password or email wrong , bullcraps", Toast.LENGTH_SHORT).show();
}
}
});
}
private void onAuthSuccess(FirebaseUser user) {
//String username = usernameFromEmail(user.getEmail())
if (user != null) {
//Toast.makeText(signinActivity.this, user.getUid(), Toast.LENGTH_SHORT).show();
ref = FirebaseDatabase.getInstance().getReference().child("users").child(user.getUid()).child("type");
ref.addListenerForSingleValueEvent(new ValueEventListener() {
#Override
public void onDataChange(DataSnapshot dataSnapshot) {
String value = dataSnapshot.getValue(String.class);
//for(DataSnapshot snapshot : dataSnapshot.getChildren()){
// Toast.makeText(signinActivity.this, value, Toast.LENGTH_SHORT).show();
if(Integer.parseInt(value) == 1) {
//String jason = (String) snapshot.getValue();
//Toast.makeText(signinActivity.this, jason, Toast.LENGTH_SHORT).show();
startActivity(new Intent(signinActivity.this, MainActivity.class));
Toast.makeText(signinActivity.this, "You're Logged in as Seller", Toast.LENGTH_SHORT).show();
finish();
} else {
startActivity(new Intent(signinActivity.this, BuyerActivity.class));
Toast.makeText(signinActivity.this, "You're Logged in as Buyer", Toast.LENGTH_SHORT).show();
finish();
}
}
#Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
}
I suggest you have this kind of structure in your database
users
---details...
---type
The type key would now contain whether your user is normal or a teacher.
Now using FirebaseAuthentication which I think you already have integrated in your app, you could use:
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
to get the currently logged in user. With that, you can now use:
String uid = user.getUid();
in order to get the UID of the currently logged in user which I think you have used as the key for your users.
Now with the UID ready, you could use a Firebase query to get the type of that specific user and go to the specific Activity based on their type.
Query userQuery = FirebaseDatabase.getInstance().getReference()
.child("users").orderByKey().equalTo(uid);
userQuery.addValueEventListener(new ValueEventListener() {
#Override
public void onDataChange(DataSnapshot dataSnapshot) {
String type = dataSnapshot.child("type").getValue().toString();
if(type.equals("Teacher"){
//Go to TeacherMemberActivity
} else {
//Go to NormalMemberActivity
}
}
#Override
public void onCancelled(DatabaseError databaseError) {
}
});
You can verify what group a user belongs(teacher or user) by attaching an event listener inside the FirebaseAuth.AuthStateListener and redirecting the user to the appropriate activity as follows
private FirebaseAuth.AuthStateListener mAuthListener;
private DatabaseReference ref;
mAuthListener = new FirebaseAuth.AuthStateListener() {
#Override
public void onAuthStateChanged(#NonNull FirebaseAuth firebaseAuth) {
FirebaseUser user = firebaseAuth.getCurrentUser();
if (user != null) {
ref = FirebaseDatabase.getInstance().getReference().child("hire-teachers").child("teachers");
ref.addListenerForSingleValueEvent(new ValueEventListener() {
#Override
public void onDataChange(DataSnapshot dataSnapshot) {
for(DataSnapshot snapshot : dataSnapshot.getChildren()){
if(FirebaseAuth.getInstance().getCurrentUser().getUid().equals(snapshot.getKey())){
startActivity(new Intent(SignInActivity.this, Teacher_memberActivity.class));
}
}
startActivity(new Intent(SignInActivity.this, Normal_memberActivity.class));
}
#Override
public void onCancelled(DatabaseError databaseError) {
}
});
} else {
// User is signed out
}
// ...
}
};
In the above implementation of the Firebase API, I am checking to see if the user is a teacher. if true then start the Teacher_memberActivity if not, start the Normal_memberActivity.
Here is the new code:
private FirebaseAuth.AuthStateListener mAuthListener;
private DatabaseReference ref;
mAuthListener = new FirebaseAuth.AuthStateListener() {
#Override
public void onAuthStateChanged(#NonNull FirebaseAuth firebaseAuth) {
FirebaseUser user = firebaseAuth.getCurrentUser();
if (user != null) {
ref = FirebaseDatabase.getInstance().getReference().child("hire-teachers").child("teachers");
ref.addListenerForSingleValueEvent(new ValueEventListener() {
#Override
public void onDataChange(DataSnapshot dataSnapshot) {
Boolean boolean = false;
for(DataSnapshot snapshot : dataSnapshot.getChildren()){
if(FirebaseAuth.getInstance().getCurrentUser().getUid().equals(snapshot.getKey())){
boolean = true;
}
}
if(boolean){
startActivity(new Intent(SignInActivity.this, Teacher_memberActivity.class));
}else{
startActivity(new Intent(SignInActivity.this, Normal_memberActivity.class));
}
}
#Override
public void onCancelled(DatabaseError databaseError) {
}
});
} else {
// User is signed out
}
// ...
}
};
I'm trying to update my android code in the new Firebase after May 2016's update, but am running into issues. Previously my user create worked fine with
Firebase ref = new Firebase("https://project.firebaseio.com");
ref.createUser(email, password, new Firebase.ValueResultHandler<Map<String, Object>>() {
#Override
public void onSuccess(Map<String, Object> result) {
System.out.println("Successfully created user account with uid: " + result.get("uid"));
error.setText("Account successfully created.");
}
#Override
public void onError(FirebaseError firebaseError) {
error.setText("Error with account creation");
}
});
but with the new system where I'm told I need to implement the system here: https://firebase.google.com/docs/auth/android/password-auth, I'm getting error
Cannot resolve method AddOnCompleteListener
whenever I try to put the method inside of an Android clickListener (how I'm sending the login data)
My (relevant) code is
FirebaseAuth mAuth = FirebaseAuth.getInstance();
FirebaseAuth.AuthStateListener mAuthListener;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.content_login);
mAuthListener = new FirebaseAuth.AuthStateListener() {
#Override
public void onAuthStateChanged(#NonNull FirebaseAuth firebaseAuth) {
FirebaseUser user = firebaseAuth.getCurrentUser();
if (user != null) {
// User is signed in
//Log.d(TAG, "onAuthStateChanged:signed_in:" + user.getUid());
} else {
// User is signed out
// Log.d(TAG, "onAuthStateChanged:signed_out");
}
// ...
}
};
#Override
protected void onStart() {
super.onStart();
mAuth.addAuthStateListener(mAuthListener);
mCreateNew.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
EditText editText = (EditText) findViewById(R.id.email);
String email = editText.getText().toString();
editText = (EditText) findViewById(R.id.password);
String password = editText.getText().toString();
mAuth.createUserWithEmailAndPassword(email, password).addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
#Override
public void onComplete(#NonNull Task<AuthResult> task) {
Log.d(logStr, "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(getApplicationContext(), "Authentication failed.",
Toast.LENGTH_SHORT).show();
}
}
});
}
});
}
mLogin.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
EditText editText = (EditText) findViewById(R.id.email);
String email = editText.getText().toString();
editText = (EditText) findViewById(R.id.password);
String password = editText.getText().toString();
mAuth.signInWithEmailAndPassword(email, password)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
#Override
public void onComplete(#NonNull Task<AuthResult> task) {
Log.d(logStr, "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(logStr, "signInWithEmail", task.getException());
Toast.makeText(getApplicationContext(), "Authentication failed.",
Toast.LENGTH_SHORT).show();
}
}
});
}
});
Reading through the new Firebase guide, it mentions that these new listeners wait for an update on the user's "sign in state" but doesn't really go into detail on that. How do I make it so that I can call the sign-in/create-new only when I click the buttons?
I know that taking the code outside of the clicklistener "solves" the problem, but then I don't know how to be able to control when the user sends login data.
I found a similar question that answers mine Firebase 9.0.0 mAuth.signInWithEmailAndPassword, how to pass it to a button
It seems that this issue is common enough that it necessitates more clarification on the Firebase site. Basically, .addOnCompleteListener() needs to be declared as it's own class within the login activity.
mAuth.signInWithEmailAndPassword(email, password)
.addOnCompleteListener(LoginActivity.this, new OnCompleteListener<AuthResult>() {