2016-11-05 61 views
0

我正在使用以下步驟註冊新的Firebase用戶。有沒有辦法讓我設置一個username參數,以便用戶在將來可以使用username & password登錄?註冊不帶電子郵件地址的Firebase用戶

此外,有沒有辦法只能使用username & password註冊,也就是說,我不想有電子郵件ID的選項。

我已經通過了以下解決方案,但效率不高。我想有更好的方法。

Firebase login and signup with username

private FirebaseAuth auth; 

    //Get Firebase auth instance 
    auth = FirebaseAuth.getInstance(); 


    //create user 
    auth.createUserWithEmailAndPassword(email, password) 
    .addOnCompleteListener(SignupActivity.this, new OnCompleteListener<AuthResult>() { 
          @Override 
          public void onComplete(@NonNull Task<AuthResult> task) { 
           Toast.makeText(SignupActivity.this, "createUserWithEmail:onComplete:" + task.isSuccessful(), Toast.LENGTH_SHORT).show(); 
           // 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(SignupActivity.this, "Authentication failed." + task.getException(), 
              Toast.LENGTH_SHORT).show(); 
           } else { 
            startActivity(new Intent(SignupActivity.this, MainActivity.class)); 
            finish(); 
           } 
          } 
         }); 

回答

0

您可以添加任何域的用戶名

背後註冊<用戶名用戶> @ summersApp.com。

請注意,由於Firebase使用電子郵件地址發送密碼重設電子郵件,因此用戶無法在忘記密碼時重置密碼。

+0

是的。這是我最關心的問題。另外,任何向用戶類添加額外參數的方式?喜歡沒有帖子?沒有朋友等? – Zen

+0

在/ users/uid保存關於用戶的所有詳細信息 – Nirel

+0

您能分享一些關於保存用戶詳細信息的代碼嗎? – Zen

相關問題