2017-10-16 3 views
0

내 전화 번호와 이메일 비밀번호 인증을 연결하려고합니다. 따라서 아래 단계를 사용하여 등록을합니다.Firebase 전화 인증 및 연결

  1. 사용자가 이메일 주소와 비밀번호를 입력합니다. 나는 그러나, 나는 어떤 연결이 표시되지 않는 firebase.auth().currentUser.linkWithPhoneNumber("+xxxxxxxxxx", xxx)

을 사용하고 있으므로

  • 은 내가 전화 번호를 현재 계정을 연결해야합니다 다음
  • firebase.auth().createUserWithEmailAndPassword(values.email, values.password)를 호출합니다. 내 firebase 콘솔에서 생성 된 2 개의 계정과 현재 사용자는 자신의 세부 사항에서만 전화 번호를 가지고 있습니다. 내가 이메일과 비밀번호로 다시 로그인하고 사용자 정보를 확인하면 전화 번호가 표시되지 않습니다 !!! 당신은 새 사용자를 만들고 전화 자격 증명을 사용하여 signInWithCredential를 호출

    onSubmit(values) { 
        this.props.firebase.auth().createUserWithEmailAndPassword(values.email, values.password).then((user) => { 
         //send recaptchaverifier 
         window.recaptchaVerifier.verify(); 
    
        }).catch((error) => { 
         console.log(error); 
        }); 
    } 
    
    
    window.recaptchaVerifier = new firebase.auth.RecaptchaVerifier('submit-button', { 
         'size': 'invisible', 
         'callback': function(response){ 
         //called when we call "window.recaptchaverifier.verify() in 
         //onSubmit function 
          var xxx = window.recaptchaVerifier; 
    
          this.props.firebase.auth().currentUser.linkWithPhoneNumber("+xxxxxxxx", xxx) 
           .then((verificationId) => { 
            console.log('inside'); 
            console.log(resp); 
            var verificationCode = window.prompt('Please enter the verification ' + 
             'code that was sent to your mobile device.'); 
            return firebase.auth.PhoneAuthProvider.credential(resp.verificationId, 
             verificationCode); 
           }).then((phoneCredential) => { 
           console.log("RESULT OF AUTH", phoneCredential); 
           console.log("USER INFO: ", this.props.firebase.auth().currentUser); 
           return this.props.firebase.auth().signInWithCredential(phoneCredential) 
          }).catch((error) => { 
           console.log("ERRORS: ", error); 
          }).catch((error) => { 
           console.log("ERROR", error) 
          }); 
         }.bind(this) 
        }); 
    
  • 답변

    0

    :

    아래에있는 내 코드를 찾아주세요. 다음을 수행해야합니다.

    firebase.auth().currentUser.linkWithPhoneNumber("+xxxxxxxx", xxx) 
        .then((confirmationResult) => { 
        // At this point SMS is sent. Ask user for code. 
        let code = window.prompt('Please enter the 6 digit code'); 
        return confirmationResult.confirm(code); 
        }) 
        .then((result) { 
        // Phone credential now linked to current user. 
        // User now can sign in with email/pass or phone. 
        }); 
        .catch((error) => { 
        // Error occurred. 
        });