From f494e2aa0b9f193fb073fba8fee87d595718f4bf Mon Sep 17 00:00:00 2001 From: Miodec Date: Mon, 14 Nov 2022 18:38:11 +0100 Subject: [PATCH] handling recover email --- frontend/static/email-handler.html | 74 ++++++++++++++++++++++++++++-- 1 file changed, 70 insertions(+), 4 deletions(-) diff --git a/frontend/static/email-handler.html b/frontend/static/email-handler.html index af66f1564..ebde190ed 100644 --- a/frontend/static/email-handler.html +++ b/frontend/static/email-handler.html @@ -196,9 +196,9 @@ `` ); $("#middle .preloader .text").text( - `Your email address has been verified.` + `Your email address has been verified` ); - $("#middle .preloader .subText").text(`You can now close this tab.`); + $("#middle .preloader .subText").text(`You can now close this tab`); }) .catch((error) => { $("#middle .preloader .icon").html( @@ -260,10 +260,10 @@ `` ); $("#middle .preloader .text").text( - `Your password has been changed.` + `Your password has been changed` ); $("#middle .preloader .subText").text( - `You can now close this tab.` + `You can now close this tab` ); firebase @@ -291,6 +291,72 @@ }); } + function handleRecoverEmail(auth, actionCode, lang) { + // Localize the UI to the selected language as determined by the lang + // parameter. + var restoredEmail = null; + // Confirm the action code is valid. + firebase + .auth() + .checkActionCode(actionCode) + .then((info) => { + // Get the restored email address. + restoredEmail = info["data"]["email"]; + + // Revert to the old email. + return auth.applyActionCode(actionCode); + }) + .then(() => { + $("#middle .preloader .icon").html( + `` + ); + $("#middle .preloader .text").text( + `Your account email was reverted.` + ); + $("#middle .preloader .subText").text(``); + + $("#middle .preloader").append(` +
+ In case you believe your account was compromised, please request a password reset email: + `); + $("#middle .preloader").append(` +
+
Send Password Reset Email
+ `); + + // Account email reverted to restoredEmail + + // TODO: Display a confirmation message to the user. + + // You might also want to give the user the option to reset their password + // in case the account was compromised: + }) + .catch((error) => { + $("#middle .preloader .icon").html( + `` + ); + $("#middle .preloader .text").text(error.message); + }); + } + + function sendPasswordResetEmail(email) { + auth + .sendPasswordResetEmail(email) + .then(() => { + $("#middle .preloader .icon").html( + `` + ); + $("#middle .preloader .text").text(`Password reset email sent`); + $("#middle .preloader .subText").text(`Please check your inbox`); + }) + .catch((error) => { + $("#middle .preloader .icon").html( + `` + ); + $("#middle .preloader .text").text(error.message); + }); + } + function getParameterByName(name, url = window.location.href) { name = name.replace(/[\[\]]/g, "\\$&"); var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),