2016-10-09 4 views
0

Firebase를 사용하여 등록 사용자에게 확인 이메일을 보내고 싶습니다.AngularJS Firebase sendEmailVerification이 작동하지 않습니다.

내 등록 컨트롤러는 다음과 같다 :

app.controller("MyregisterCtrl", ["$scope", "firebase", "$firebaseAuth", "$location", function ($scope, firebase, $firebaseAuth, $location) { 

    $scope.signUp = function() { 
     var username = $scope.user.email; 
     var password = $scope.user.password; 


     if (username && password) { 
      var auth = $firebaseAuth(); 
      var user = firebase.auth().currentUser; 

      auth.$createUserWithEmailAndPassword(username, password) 
      user.sendEmailVerification() 
       .then(function() { 
        console.log("User signup success"); 
        $scope.errMsg = false; 
        $location.path('/login.signin'); 
       }).catch(function (error) { 
       $scope.errMsg = true; 
       $scope.errorMessage = error.message; 
      }); 
     } 
    } 

}]); 

사용자는 중포 기지 사용자 데이터베이스에 등록됩니다. 하지만 확인 이메일을 받으려면 제출 버튼을 세 번 클릭해야합니다. 아주 이상한.

왜 첫 번째 제출 클릭시 보내지 않습니까? 여기

오류 스크린 샷입니다 :

enter image description here

답변

2

사용자 계정을 만드는 것은 시간이 걸릴 수있는 작업입니다. 작업이 완료되기 전에 sendEmailVerification()로 전화하면 스크린 샷에 오류 메시지가 표시됩니다. 향후 질문은 텍스트 사진을 게시하지 말고 실제 텍스트를 게시하십시오.

auth.$createUserWithEmailAndPassword(username, password) 
    .then(function(user) { 
     user.sendEmailVerification() 
    }).then(function() { 
     console.log("User signup success"); 
     $scope.errMsg = false; 
     $location.path('/login.signin'); 
    }).catch(function (error) { 
     $scope.errMsg = true; 
     $scope.errorMessage = error.message; 
    }); 

그래서 여기 순서 :

  1. 사용자 계정을 만들 계정을 해결하기 위해 소위 약속을 기다리고에 의해 생성 될 때까지

    문제를 해결하기 위해, 당신은 기다릴 수 있습니다

  2. 일단 성공하면 확인 이메일을 보내십시오.
  3. 성공하면 로그 성공과 리디렉션
  4. 1 또는 2 중 하나가 실패하면 오류 메시지 표시
관련 문제