Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Dan 1250 posts 3747 karma points admin c-trib
    Mar 10, 2014 @ 13:33
    Dan
    0

    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.

  • Andy Butland 373 posts 2057 karma points MVP 4x hq c-trib
    Mar 10, 2014 @ 14:11
    Andy Butland
    0

    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.

  • Dan 1250 posts 3747 karma points admin c-trib
    Mar 10, 2014 @ 14:25
    Dan
    0

    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?

  • Andy Butland 373 posts 2057 karma points MVP 4x hq c-trib
    Mar 10, 2014 @ 14:36
    Andy Butland
    100

    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.

     

  • Dan 1250 posts 3747 karma points admin c-trib
    Mar 10, 2014 @ 15:10
    Dan
    0

    Thanks for the confirmation Andy, I'll get stuck in and see if I can make it work.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies