I'm using firebase in my web app with Ionic and I would like to redirect the user to a specific page (the login page, in my case) after he clicks on the link in the verification email.
At the moment, when the user clicks on the verification link, he is redirected on another browser page that says that he has confirmed the email.
I would like to redirect him directly to a page of my web app, without passing through that confirmation.
Is it possible to do that?
The Android app needs to be registered in the Console. Whether the email action link will be opened in a mobile app or a web link first. The default is false. When set to true, the action code link will be be sent as a Universal Link or Android App Link and will be opened by the app if installed.
oobCode. A one-time code, used to identify and verify a request. apiKey. Your Firebase project's API key, provided for convenience.
You can use Firebase Authentication to sign in a user by sending them an email containing a link, which they can click to sign in. In the process, the user's email address is also verified. There are numerous benefits to signing in by email: Low friction sign-up and sign-in.
I couldn't get any of the solutions here to work. So after looking up the docs I found that you add a continue URL after the email verification to which the firebase will redirect to after confirming. https://firebase.google.com/docs/auth/web/passing-state-in-email-actions
After email is verified you might also have to force refresh the firebase token if you use email_verified
in your firebase rules.
You can do what I did.
ActionCodeSettings
to sendEmailVerification.auth.createUserWithEmailAndPassword(email, password) .then((res) => { res.user.sendEmailVerification({ url: "https://example.com/path?confirm_email=true", }); return createUser({ email, uid: res.user.uid, name }); })
This will make firebase redirect to https://example.com/path?confirm_email=true
after email verification. The confirm_email
is so that I know when to force refresh the firebase token.
(Optional)
const urlParams = new URLSearchParams(window.location.search); const isConfirmingEmail = urlParams.get('confirm_email'); auth.currentUser.getIdToken(!!isConfirmingEmail).then(() => { // Refreshed Token })
Yes it's possible. Look in the firebase.console on the left for "Authentication". Then find "Templates" and look for "Email address verification". I think it's default opened. On the template you will see a small pencil, click on it. After that you can change your template however you want. At the bottom you will find the link "customize action URL". Open this link, paste your URL in the modal window and save. That's it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With