2016-07-02 3 views
2

내 방법에 비밀번호 분실 법을 어떻게 구현합니까? 곧 출시 될 HTML 프로젝트를 만들고 있습니다. 내 코드 : 여기Google Firebase 비밀번호를 잊어 버리십시오.

function toggleSignIn() { 
    if (!firebase.auth().currentUser) { 
// [START createprovider] 
var provider = new firebase.auth.GoogleAuthProvider(); 
// [END createprovider] 
// [START addscopes] 
provider.addScope('https://www.googleapis.com/auth/plus.login'); 
// [END addscopes] 
// [START signin] 
firebase.auth().signInWithPopup(provider).then(function(result) { 
    // This gives you a Google Access Token. You can use it to access the Google API. 
    var token = result.credential.accessToken; 
    // The signed-in user info. 
    var user = result.user; 
    // [START_EXCLUDE] 
    document.getElementById('quickstart-oauthtoken').textContent = token; 
    // [END_EXCLUDE] 
}).catch(function(error) { 
    // Handle Errors here. 
    var errorCode = error.code; 
    var errorMessage = error.message; 
    // The email of the user's account used. 
    var email = error.email; 
    // The firebase.auth.AuthCredential type that was used. 
    var credential = error.credential; 
    // [START_EXCLUDE] 
    if (errorCode === 'auth/account-exists-with-different-credential') { 
    alert("You have already signed up with a different auth provider for that email."); 
    // If you are using multiple auth providers on your app you should handle linking 
    // the user's accounts here. 
    } 
else if (errorCode === 'auth/auth-domain-config-required') { 
alert("An auth domain configuration is required"); 
    } 
    else if (errorCode === 'auth/cancelled-popup-request') { 
     alert("Popup Google sign in was canceled"); 
    } 
    else if (errorCode === 'auth/operation-not-allowed') { 
     alert("Operation is not allowed"); 
    } 
    else if (errorCode === 'auth/operation-not-supported-in-this-environment')  { 
     alert("Operation is not supported in this environment"); 
    } 
    else if (errorCode === 'auth/popup-blocked') { 
     alert("Sign in popup got blocked"); 
    } 
    else if (errorCode === 'auth/popup-closed-by-user') { 
     alert("Google sign in popup got cancelled"); 
    } 
    else if (errorCode === 'auth/unauthorized-domain') { 
     alert("Unauthorized domain"); 
    } 
    else { 
    console.error(error); 
    } 
    // [END_EXCLUDE] 
    }); 
    // [END signin] 
    } else { 
    // [START signout] 
    firebase.auth().signOut(); 
    // [END signout] 
    } 
    // [START_EXCLUDE] 
    document.getElementById('quickstart-sign-ing').disabled = false; 
    // [END_EXCLUDE] 
} 

는 지침 당신에게 제공하는 링크입니다 : https://firebase.google.com/docs/auth/web/manage-users#set_a_users_password 당신이 날

답변

7

비밀번호 찾기 버튼을 구현하려면, 당신은 전화를해야 도움이 될 수 있습니다하십시오 firebase.auth().sendPasswordResetEmail('[email protected]')

확인 자세한 내용은 설명서를 참조하십시오. https://firebase.google.com/docs/reference/js/firebase.auth.Auth#sendPasswordResetEmail

+0

안녕하세요. firebase auth api를 사용하여 암호 기능을 잊어 버렸습니다. sendPasswordResetEmail() 함수를 사용하면 잘 작동합니다. 그러나 firebase api doc은 "비밀번호 재설정을 완료하려면 사용자가 지정한 비밀번호와 함께 사용자에게 보낸 이메일에 제공된 코드로 firebase.auth.Auth # confirmPasswordReset을 호출하십시오." 이제 confirmPasswordReset() 함수의 param을 알고 싶습니다. confirmPasswordReset (코드), 여기 코드는 어디서 오는 것입니까? –

+0

비밀번호 재설정 이메일 링크에서 해당 코드를 구문 분석해야합니다. 사용자가 해당 페이지를 클릭합니다. 또한 자신의 방문 페이지를 호스팅하는 경우 관련성이 있습니다. Firebase 콘솔에서 수정해야합니다. – bojeil

관련 문제