[Android Studio] Firebase 회원가입, 로그인, 로그아웃

공식문서: https://firebase.google.com/docs/auth/android/password-auth?hl=ko

이메일 기반 로그인

1. 회원가입

 //회원가입 + 로그인됨
 auth.createUserWithEmailAndPassword(email, password)
     .addOnCompleteListener(this) { task ->
         if (task.isSuccessful) {
             Toast.makeText(this, "성공!!", Toast.LENGTH_SHORT).show()
         } else {
             Toast.makeText(this, "실패!!", Toast.LENGTH_SHORT).show()
         }
     }

2. 로그아웃

//로그아웃
auth.signOut()

3. 로그인

 auth.signInWithEmailAndPassword(email, password)
         .addOnCompleteListener(this) { task ->
             if (task.isSuccessful) {
                 Toast.makeText(this, "성공!!", Toast.LENGTH_SHORT).show()
             } else {
                 Toast.makeText(this, "실패!!", Toast.LENGTH_SHORT).show()
             }
         }

좋은 웹페이지 즐겨찾기