Best way to route email verification link with MVC
Hi,
I have a registration system which requires verification via an email link containing the registrant email and a guid. The link is formatted something like this:
In the days of webforms I'd probably create a custom template called 'verify' to 'accept' this URL, then add a usercontrol to the template to handle the email/guid variables to verify the account. However, I'm wondering what the best approach is with MVC? Surface Controller with route hijacking perhaps?
Yes, create a new doc type for this verification page, and hijack the route to add your logic to a custom controller action. After that you can redirect to wherever you want them to go, or present a page saying "Sorry, link not valid". That sounds good to me.
Thanks Andy. From the documentation I'm struggling a little getting my head around actually what to set up here. Am I right in saying, in my example above, that I'd need to set up a new document type and then create a content node under my 'home' node, called 'verify' which uses this new document type? So I have to actually create the node, albeit it behaves differently to a normal node as it executes my code rather than doing the regular Umbraco stuff?
Yes, that's exactly how I understand it. I expect you're on the same page, but the docs are here.
It seems to me you'll need something similar to the first example - you'll put your checks in place of the "//Do some stuff here" comment. And then either call the base method to return the template, or do a redirect.
Best way to route email verification link with MVC
Hi,
I have a registration system which requires verification via an email link containing the registrant email and a guid. The link is formatted something like this:
http://www.example.com/verify/[email protected]&g=d70ae200-9d20-4593-858d-b31dc2179eeb
In the days of webforms I'd probably create a custom template called 'verify' to 'accept' this URL, then add a usercontrol to the template to handle the email/guid variables to verify the account. However, I'm wondering what the best approach is with MVC? Surface Controller with route hijacking perhaps?
Thanks for any pointers folks.
Yes, create a new doc type for this verification page, and hijack the route to add your logic to a custom controller action. After that you can redirect to wherever you want them to go, or present a page saying "Sorry, link not valid". That sounds good to me.
Thanks Andy. From the documentation I'm struggling a little getting my head around actually what to set up here. Am I right in saying, in my example above, that I'd need to set up a new document type and then create a content node under my 'home' node, called 'verify' which uses this new document type? So I have to actually create the node, albeit it behaves differently to a normal node as it executes my code rather than doing the regular Umbraco stuff?
Yes, that's exactly how I understand it. I expect you're on the same page, but the docs are here.
It seems to me you'll need something similar to the first example - you'll put your checks in place of the "//Do some stuff here" comment. And then either call the base method to return the template, or do a redirect.
Thanks for the confirmation Andy, I'll get stuck in and see if I can make it work.
is working on a reply...