Advertisement
ismoy

AuthProviderFirebase

Sep 25th, 2021
1,165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.96 KB | None | 0 0
  1. package cl.tofcompany.todosenuno.Provider;
  2.  
  3. import com.google.android.gms.tasks.Task;
  4. import com.google.firebase.auth.AuthResult;
  5. import com.google.firebase.auth.FirebaseAuth;
  6.  
  7. import java.util.Objects;
  8.  
  9. public class AuthProvider {
  10.  
  11.     FirebaseAuth mAuth;
  12.  
  13.     public AuthProvider() {
  14.         mAuth = FirebaseAuth.getInstance();
  15.     }
  16.     public Task<AuthResult> register(String email, String password) {
  17.         return mAuth.createUserWithEmailAndPassword(email, password);
  18.     }
  19.     public Task<AuthResult> login(String email, String password){
  20.         return mAuth.signInWithEmailAndPassword(email , password);
  21.     }
  22.     public void logout(){
  23.         mAuth.signOut();
  24.     }
  25.     public String getId() {return(Objects.requireNonNull(mAuth.getCurrentUser())).getUid();}
  26.     public boolean existSession(){
  27.         boolean exist = false;
  28.         if(mAuth.getCurrentUser()!=null){
  29.             exist = true;
  30.         }
  31.         return exist;
  32.     }
  33. }
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement