Tuesday, 21 July 2020

Correct way to handle multistep verification process with Express/Pug

I'm just a little stuck on the logic of how to go about building a multistep form, not so much the implementation.I'm building a process to verify a user owns a website they claim they do. First they need to input their website and press submit, on the backend I will create a db record tying together the user, the website, and a token that I create, then the user needs to be prompted to add that text token to their website and hit verify, at this point I need to lookup the record containing the user, website, and token, scrape the site for the text, and if found mark the user as the owner.Typically when building a site like this I'll be using something like React and use Ajax calls to make the initial call and generate the token, then when the response returns with the token I'd render out the second component to verify and when submitted I'd pull the info I need from the local state and make a second ajax call. While I'm sure I could do all of this with Express/Pug it doesn't seem like the correct way to do it.Should I make a post to create the token/record, then use res.render with the same path and the new token as a param to add to best used in the verify post? Should I res.redirect back to the same page and store that new token/record in a session variable for the next call? Should I just redirect to a seperate "verify" page after the token is created? Or should I just build out ajax calls on the front end?I'm just sort of overthinking the process and want to find the correct way to do it before I get in too deep.

Submitted July 21, 2020 at 03:05PM by DasBeasto

No comments:

Post a Comment