Wednesday, 17 May 2017

User registration verification email flow with Angular2

I have a running application (in production) with node.js on the server and jQuery taking care of the client side logic. I am in the middle of converting to Angular2...

In the old node.js/jQuery app, when the user would click the link in their verification email, the route handler on node.js side after verifying everything is fine would mark the user as registered, serve a page where the user was informed they have been verified and can proceed to the login using their credentials.

I am not able to wrap my head around this: Since only index.html is ever served to the client (apart from /api/ calls to perform CRUD and other service calls), how to let Angular know that the user should be informed that their email has been verified and they are good to go.

My first thought was to tinker with the index.html in that to add a <script> tag and use ejs template vars like this; <%- window.isVerified = 'true';%>.

Or something similar and then read window.isVerified in ngOnInit and if the value is true then proceed accordingly, but this sounds clunky. Another reason to not pursue this was my use of webpack and that was another bridge to cross with it's bundling...

I am comfortable with Angular2's mechanics (I think), but this seemingly simple issue is eluding me. Will highly appreciate any pointers.



via kmansoor

No comments:

Post a Comment