Copied to clipboard

Flag this post as spam?

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


  • Son Pham 31 posts 72 karma points
    Jul 16, 2015 @ 16:38
    Son Pham
    0

    Logout manually request

    I am using built-in function UmbracoLoginController. It worked fine with login and logout. But I want to do further as If my ajax calls return 404 or 500, I would like to logout user automatically by showing a message "Your session has been timeout. ..."

    using (Html.BeginUmbracoForm<UmbLoginStatusController>("HandleLogout"))
        {
             <fieldset>
                 <legend></legend>
                 <button class="k-button">Logout</button>
             </fieldset>
    
            @Html.HiddenFor(m => logoutModel.RedirectUrl)
        }
    

    The code above work fine if user click Logout button. But how to make a request to logout user in this case without clicking on button. Thanks

  • Jason 122 posts 637 karma points
    Jul 16, 2015 @ 18:20
    Jason
    0

    Are you getting the 404 or 500 when you try to call the logout with JavaScript code? If that is the case could you post you JS script also?

  • Son Pham 31 posts 72 karma points
    Jul 16, 2015 @ 18:25
    Son Pham
    0

    Hi Jason Thanks for replying. My ajax is calling another web api service. ex: UpdateOrderInformation for instance, and this api return a 404 message with whatever. In this case I want to log out user immediately instead using built-in by clicking Logout button.

    P/s: Logout built-in function works perfectly. What I want to ask is how to force user log out instead of clicking that button.

  • Jason 122 posts 637 karma points
    Jul 17, 2015 @ 01:08
    Jason
    100

    I have not tried this but I would imagine that you could do an ajax post to the logout controller url and then just redirect the user to clear auth cookie. You could also create your own controller to log the user out, it is not required the you use the umbraco logout controller, standard form auth stuff. Hope that helps.

  • Son Pham 31 posts 72 karma points
    Jul 17, 2015 @ 08:39
    Son Pham
    0

    Thank you Json. I also found this. Hope this one will help someone else who has the same problem http://24days.in/umbraco/2012/creating-a-login-form-with-umbraco-mvc-surfacecontroller/

Please Sign in or register to post replies

Write your reply to:

Draft