+1-888-365-2779
Try Now
More in this section

Forums / Bugs & Issues / Claims authentication custom login page not redirecting to ReturnUrl

Claims authentication custom login page not redirecting to ReturnUrl

5 posts, 2 answered
  1. David
    David avatar
    29 posts
    Registered:
    28 Apr 2009
    23 Jan 2014
    Link to this post
    I am running SiteFinity 6.3 with claims based authentication. I have created a custom login page and set the FrontEndLoginPageUrl to redirect to that page. The redirect is working fine and users can log in, however after the user logs in they are not redirected to the ReturnUrl property in the querystring. Instead they are redirected back to the login page. I did some debugging in the javascript and tracked the problem down to this function:
    _getRedirectUrl: function (paramString) {
            var returnUrl;
            var docUrl = this._getReturnLocation();
            var handleRejectedUserParam = this.get_handleRejectedUserParam();
            var currentLocation = window.location.href;
            var separator = "?";
            if (currentLocation.indexOf("?") != -1) {
                separator = "&";
            } returnUrl = currentLocation + separator + paramString + "&" + handleRejectedUserParam + "=true";
            var returnUrlParam = this.get_returnUrlParam();
            if (currentLocation.indexOf(returnUrlParam) < 0) {
                returnUrl += "&" + this.get_returnUrlParam() + "=" + encodeURIComponent(docUrl);
            } return returnUrl;
        }

    The docUrl has the correct url for the page they should be redirected to however as you can see they are actually redirected to the currentLocation variable which is the login page. Is this a bug or is there a settings i have missed that caused the code to generate this way?

    Thanks
    David
  2. Viktor Bukurov
    Viktor Bukurov avatar
    2 posts
    Registered:
    29 Jul 2016
    28 Jan 2014
    Link to this post
    Hello David,

    This is the correct behavior of the JavaScript method mentioned.

    Could you give us some more information regarding this issue? 
    1. Do you have any other widgets on your login page? Sometimes widgets interfere with each other, resulting in unexpected behavior. Try creating a login page with only a login widget and then try the redirect functionality again.
    2. Did you change any properties of the login widget?
    3. Does it happen only with certain users? Or it always happens, even with an admin user?

    Regards,
    Viktor Bukurov
    Telerik
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. David
    David avatar
    29 posts
    Registered:
    28 Apr 2009
    28 Jan 2014 in reply to Viktor Bukurov
    Link to this post
    When you mentioned other widgets I realized I had a login/logout widget on my master page. Removing that fixes the issue. I seem to recall a post somewhere about a similar issue with the login/logout button causing issues that i looked at while researching another issue but i haven't been able to track it down yet. Is there a way for these two widgets to coexist or do I need to write a custom login/logout widget?
  4. Sabrie Nedzhip
    Sabrie Nedzhip avatar
    534 posts
    Registered:
    09 Dec 2016
    31 Jan 2014
    Link to this post
    Hi David,

    You can try to add the code below in the InitializeControls() method of your custom login widget in order to redirect the successfully logged in user to the page specified in the returnUrl property in the query string:

    var returnUrl = HttpContext.Current.Request.QueryString["ReturnUrl"];
      
    if (ClaimsManager.GetCurrentIdentity().IsAuthenticated &&
                !string.IsNullOrWhiteSpace(returnUrl))
    {
    currentContext.Response.Redirect(returnUrl, true);
    }


    Regards,
    Sabrie Nedzhip
    Telerik
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
    Answered
  5. David
    David avatar
    29 posts
    Registered:
    28 Apr 2009
    31 Jan 2014 in reply to Sabrie Nedzhip
    Link to this post
    I actually ended up just creating a separate master page for my login page that does not have the login/logout widget on it but that would be an effective work around. I also opened a ticket with Telerik and they said this is a known bug that should be fixed in a future release. 
    Answered
5 posts, 2 answered