I would like to build a custom email change flow.
It should work like this:
- The user triggers an email reset from the front end.
- The server sends a link to his mailbox.
- The user clicks on the link and is redirected to a page with 2 input fields where he enters the new email.
- The server changes the email and sends another confirmation email to both new and old addresses.
Can some seasoned parse developer outline what needs to be done? If I can do it I’ll share a detailed walkthrough here.
Thanks
I started with adding a custom route.
pages: {
enableRouter: true,
customRoutes: [
{
method: "GET",
path: "/change_email",
handler: async (request) => {
return {
file: "invalid_verification_link.html",
};
},
},
],
},
The file is a dummy just for the test.
Yet, I get an unauthorized error when visiting the route below:
(http://localhost:3001/parse/app/REhm2i4UjtiaujvIP302aCky2hkvDqnm9wLS4WyK/change_email)
and this one
(http://localhost:3001/parse/public/REhm2i4UjtiaujvIP302aCky2hkvDqnm9wLS4WyK/change_email)
The html is located in the public folder.
Why am I getting 403 and how to get permission to access this file?
Thank you.
I went the other route:
- User initiates email reset on frontend.
- The request triggers this cloud function that sends the user a random code via email and saves the number to DB.
Parse.Cloud.sendEmail({
from: "Excited User <[email protected]>",
to: result.attributes.email,
subject: "Confirmation code for changing your email",
text: `Hi ${result.attributes.name}. Your confirmation code is ${randomCode}.`,
})
- The user then has to input the number received via email into the frontend.
- Another cloud function compares the input number with the one stored in the DB, and if they match updates the email.
Thank you @dblythy for the awesome cloud email send function.
1 Like