[英]Customize Firebase "email validation", "password reset" pages
I'm using Firebase and Firestore auth in an angular application(with angular-fire), which works nicely.我在 Angular 应用程序(使用 angular-fire)中使用 Firebase 和 Firestore 身份验证,效果很好。 For the feature "password forgotten" and "email validation", I do call those methods on the
AngularFireAuth
service:对于“忘记密码”和“电子邮件验证”功能,我确实在
AngularFireAuth
服务上调用了这些方法:
sendVerificationMail() {
return this.afAuth.currentUser
.then((u: any) => u.sendEmailVerification())
.then(() => {
this.router.navigate(['/', 'auth', 'verify-email']);
});
}
async forgotPassword(passwordResetEmail: string) {
try {
await this.afAuth.sendPasswordResetEmail(passwordResetEmail);
window.alert('Password reset email sent, check your inbox.');
} catch (error) {
window.alert(error);
}
}
It works, I receive email to validate my email or to reset my password, but:它有效,我收到电子邮件以验证我的电子邮件或重置我的密码,但是:
https://xxxx.firebaseapp.com
instead of my custom domainhttps://xxxx.firebaseapp.com
这样的 URL,而不是我的自定义域 My question is, can I provide URL to some custom page?我的问题是,我可以提供一些自定义页面的 URL 吗? Or customize the design?
还是定制设计? Or some redirect action?
或者一些重定向动作? To have something that is a bit better integrated to my website?
将一些更好地集成到我的网站的东西?
This is for redirect after password reset, You have to pass a continue URL via ActionCodeSettings to redirect the user back to the app:这是密码重置后的重定向,您必须通过 ActionCodeSettings 传递一个继续 URL 以将用户重定向回应用程序:
var actionCodeSettings = {
// After password reset, the user will be give the ability to go back
// to this page.
url: 'https://www.example.com/afterPasswordReset',
handleCodeInApp: false
};
firebase.auth().sendPasswordResetEmail(email, actionCodeSettings)
.then(function() {
// Password reset email sent.
})
.catch(function(error) {
// Error occurred. Inspect error.code.
});
Learn more about ActionCodeSettings and passing state in redirect: https://firebase.google.com/docs/auth/web/passing-state-in-email-actions详细了解 ActionCodeSettings 和重定向中的传递状态: https ://firebase.google.com/docs/auth/web/passing-state-in-email-actions
You can also build your own custom landing page here: https://firebase.google.com/docs/auth/custom-email-handler您还可以在此处构建自己的自定义登录页面: https ://firebase.google.com/docs/auth/custom-email-handler
You can customize the Password Reset email under Firebase Console -> Auth -> Email Templates -> Password Reset, and change the link in the email to point to your own page.您可以在 Firebase 控制台 -> 身份验证 -> 电子邮件模板 -> 密码重置下自定义密码重置电子邮件,并将电子邮件中的链接更改为指向您自己的页面。 Note that the
placeholder will be replaced by the password reset code in the URL.
请注意,
placeholder will be replaced by the password reset code in the URL.
Then, in your custom page, you can read the password reset code from the URL and do
firebase.auth().confirmPasswordReset(code, newPassword)
.then(function() {
// Success
})
.catch(function() {
// Invalid code
})
https://firebase.google.com/docs/reference/js/firebase.auth.Auth#confirmPasswordReset https://firebase.google.com/docs/reference/js/firebase.auth.Auth#verifyPasswordResetCode https://firebase.google.com/docs/reference/js/firebase.auth.Auth#confirmPasswordReset https://firebase.google.com/docs/reference/js/firebase.auth.Auth#verifyPasswordResetCode
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.