Copied to clipboard

Flag this post as spam?

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


  • Sebastian Dammark 581 posts 1385 karma points
    Jan 29, 2017 @ 23:39
    Sebastian Dammark
    0

    Simple Rule Protection login returns to login

    I've created a page with Simple Rule Protection and a Login Page and an Error Page.

    When I enter the protected page, I'm redirected to the Login page, which is what I've expected.

    But when I login with username and password, I'm redirected back to the login page and not to the protected page as I've expected.

    If I then manually go to the protected page I'm no loger required to enter username and password. So apparently I've used the correct username and password, but I've been redirected to the wrong page after login.

    How do I get redirected to the right page after login ?

  • Rasmus Fjord 675 posts 1566 karma points c-trib
    Jan 31, 2017 @ 14:43
    Rasmus Fjord
    0

    That really depends on your login page implementation.

    Normally when you see the login page, the url of the page is not the url for the Login page but for your hidden page.

    And after correct login it would redirect to the same url.

    How is your login.cshtml?

  • Sebastian Dammark 581 posts 1385 karma points
    Jan 31, 2017 @ 20:20
    Sebastian Dammark
    0

    Hi Rasmus,

    My login.cshtml looks like the example in this post: https://our.umbraco.org/forum/umbraco-7/using-umbraco-7/71701-basic-member-login-form-umbraco

    When I enter the protected page, I'm not redirected to the login page, my mistake. But I do see the login form. But when I submit that form I'm redirected to the /login page.

  • Chriztian Steinmeier 2798 posts 8787 karma points MVP 7x admin c-trib
    Jan 31, 2017 @ 21:48
    Chriztian Steinmeier
    100

    Hi Sebastian,

    I've encountered this too - the default "Login.cshtml" snippet you're encouraged to use when building a simple login system, doesn't redirect you to the URL you originally requested.

    I re-jigged it for my own purpose once — if I remember correct, you just need to add a hidden field for the RedirectUrl to the form, like this:

    var loginModel = new LoginModel();
    loginModel.RedirectUrl = HttpContext.Current.Request.Url.AbsolutePath;
    
    ...
    
    @using (Html.BeginUmbracoForm<UmbLoginController>("HandleLogin"))
    {
        @Html.HiddenFor(m => loginModel.RedirectUrl)    
    
        <fieldset>
            <legend>Login</legend>
            ...
    }
    

    /Chriztian

Please Sign in or register to post replies

Write your reply to:

Draft