Copied to clipboard

Flag this post as spam?

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


  • Pat O'Callaghan 34 posts 56 karma points
    Jun 22, 2010 @ 06:55
    Pat O'Callaghan
    0

    Retrieving original destination node when redirected to Login page

    Hey all,

    on my site I have a public area and a members area with a login form at the top of each page.

    The functionality I want is, if a user logs in from anywhere in the public area of the site they will get redirected to the Members area 'homepage'. On the other hand if they are hitting a protected/members part of the site (i.e. Deep linking) and need to login first they will continue to that page.

    What I was planning on doing on login was the following:

    if (umbraco.library.IsProtected(currentNode.Id,currentNode.Path)) {
            context.Response.Redirect(context.Request.Url.ToString());
    } else  { 
     context.Response.Redirect("/");
     }

    So if the page is protected (i.e. a member page) it just goes to that page, otherwise, it means the user is logging in from a public page and will be redirected to the member homepage.

    For the protected pages in the CMS I've set up the Error and Login pages so when deep linking and the user isn't logged in, it redirects to a login page. The problem I've found is when the user gets redirected to the login page, I no longer know what the currentNode is, i.e. what was deep linked, as currentNode in this line of code

     

    umbraco.library.IsProtected(currentNode.Id,currentNode.Path)

    now always refers to the Login node.

    Is there I can find out what the original node the user was trying to access is?

    Thanks,

    Pat

  • Sebastiaan Janssen 5045 posts 15476 karma points MVP admin hq
    Jun 23, 2010 @ 02:12
    Sebastiaan Janssen
    0

    Since you're handling the redirect anyway, why not attach the referring URL (Request.UrlReferrer.ToString()) to the querystring?

  • Pat O'Callaghan 34 posts 56 karma points
    Jun 25, 2010 @ 03:49
    Pat O'Callaghan
    0

    Hi Sebastien,

     

    thanks for your response. The problem I am having though is related to the isProtected check as the currentNode is actually set to the login page node assigned to the protected page, not the page I was originally trying to access. So when I do the isProtected check it always comes back as false as the login page is not protected, but the original page I was trying to access is.

  • Sebastiaan Janssen 5045 posts 15476 karma points MVP admin hq
    Jun 25, 2010 @ 12:02
    Sebastiaan Janssen
    0

    How about a check for isProtected AND whether you're on the login page?

  • Pat O'Callaghan 34 posts 56 karma points
    Jun 26, 2010 @ 03:19
    Pat O'Callaghan
    0

    No, unfortunately that won't work because I'm trying to find out if the referring page isProtected but I never can as the currentNode is ALWAYS set to the login page.

  • Anders Brännmark 226 posts 277 karma points
    Jun 28, 2010 @ 21:01
    Anders Brännmark
    0

    Are you protecting you pages with umbraco password protected pages? If so I assume you have the "refering" url visible in the browsers url field? But when you check currentpage you are on your login page?

    Then you can use the rawurl method of the request object to figure where the user was before ending up on you login page. This however is not the best solution. If Umbraco only had used the ReturnUrl property it would have been very nice. I setup a content picker on my "member" doctypes to redirect to the page I want after an "action". I also have a content picker for which is the startpage for my member pages, this is used on the login page. So when a user login from a page that isnt protected I use this "startnode" property to redirect the user.

    Make any sense?  

  • Pat O'Callaghan 34 posts 56 karma points
    Jul 08, 2010 @ 11:04
    Pat O'Callaghan
    0

    Hi Anders,

    thanks for the reply but have been away from the forum.

    I have a question with this line "So when a user login from a page that isnt protected I use this "startnode" property to redirect the user". How do you know that the page is/isn't protected because whenever I check using isProtected it always comes back as "false" (not protected) because the login node which I've been redirected to is not a protected node. Sorry if it's blatantly obvious but this is where I'm having the trouble.

    Thanks,

    Pat

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jan 12, 2011 @ 09:13
    Dirk De Grave
    0

    Hi Pat, 

     

    Just a different idea: why not have two login controls, the first one on top of each page (probably in the masterpage), and use the events on the login control to redirect to the member's homepage on succesful login.

    Other login control is on the specified 'Login' page set through the dialog to protect a section of the site. No need for extra code as the login will redirect to the page user was on

    No need to check on protected pages using the umbraco library functions anymore

    I've done this on several sites and haven't had any issues with that.

    Hope that makes sense.

    Cheers,

    /Dirk

  • Giovanni Sidoel 94 posts 233 karma points
    May 16, 2012 @ 20:40
    Giovanni Sidoel
    0

    Really old post, but I'm having the same problem as Pat. I'm working on  anews site on which the newspages are protected. what I want to do is show part of the article when not logged in and a login form. And the full content when logged in.
    For me to do this I need to know the nodeId of the destination (the page that the user is trying to access). Is this possible?

    How does Umbraco know where to redirect the user to after succesfull login? 

  • Giovanni Sidoel 94 posts 233 karma points
    May 17, 2012 @ 13:13
    Giovanni Sidoel
    0

    Just FYI,

    I got this question answered on a different thread if anyone else has the same issue. See http://our.umbraco.org/forum/developers/xslt/31794-Is-it-possible-to-retrieve-the-destination-node-when-redirected-to-Login-using-XSLT

    Use GetNodeIdByUrl(string url) by uComponents.

Please Sign in or register to post replies

Write your reply to:

Draft