0
當新用戶註冊Web應用程序時,會向他發送驗證電子郵件。我阻止新用戶在驗證之前登錄。未驗證用戶的Firebase句柄重置密碼電子郵件
與此同時,如果驗證鏈接到期並且用戶忘記密碼,他將單擊重置密碼鏈接並收到電子郵件。
所以我認爲我應該一起處理重置密碼操作和驗證。否則,即使更改密碼後,用戶也將無法登錄。
function handleResetPassword(auth, actionCode) {
auth.verifyPasswordResetCode(actionCode)
.then(function (email) {
// Showing the reset screen and ask the user for
// the new password.
}).catch(function (error) {
//
});
};
當用戶保存新密碼:
function saveNewPassword() {
auth.confirmPasswordReset(actionCode, vm.form.password).then(function (resp) {
// Password reset has been confirmed and new password updated.
// Now auto sign in user
auth.signInWithEmailAndPassword(vm.email, vm.form.password).catch(function (error) {
// Handle Errors here.
});
firebase.auth().onAuthStateChanged(function (user) {
if (user) {
// user signed in.
// check whether the user is verified
// if not set true
user.updateProfile({ emailVerified: true })
}
});
}).catch(function (error) {
//
});
}
但下面的代碼,如我所料,因爲它沒有影響不起作用。我可以更改其他用戶數據(例如displayName),但不能更改(emailVerified)。它只適用於Firebase電子郵件驗證。
user.updateProfile({ emailVerified: true })
這種類型的用戶場景的推薦方法是什麼?
目前我使用自定義電子郵件處理程序相同的firebase文檔中描述。我沒有後端服務器。我的網站應用託管在firebase上。我搜索了firebase雲功能來處理這個,但我不能。我認爲你的示例代碼不適用於雲功能? –
您需要使用Firebase函數構建HTTP端點來處理此問題。查看文檔以瞭解更多信息,方法如下:https://firebase.google.com/docs/functions/http-events – bojeil