Copied to clipboard

Flag this post as spam?

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


  • Rohan 105 posts 162 karma points
    Apr 13, 2015 @ 14:44
    Rohan
    0

    how Public Access -> single user protection -> login page

    Hi

    I am using Umbraco 7.2x

    I have the requirement where one of my page should not be access publically. Not all user can be able to access this page.

    One way i have found that I can create one login Page where admin can enter the credentials and access the page

    OR

    I have found that i can use 'Public Access' option for any node inside the Content. So i have choossen "Single User Protection" where i need to add User Name & Password  and select the login & error page. My question is that if i define login page with "Login" button then do i need to write any CODE to validate the admin entered details(username, password) with the detail we have added in Umbraco 'Public Access -> Single User Protection" ? 

    If yes then can any one pleaes let me guide here ?

    thanks in advance !

    rohan 

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    Apr 13, 2015 @ 15:12
    Dennis Aaen
    0

    Hi Rohan,

    In Umbraco 7, there is a razor code snippet for a login funtionallty it´s called Login this will gives you a login form, with validation too. Here is also a video chapter on Umbraco TV, how to work with public access. http://umbraco.tv/videos/umbraco-v7/content-editor/administrative-content/members/role-based-protection/

    Hope this helps,

    /Dennis

  • Matthew Kirschner 323 posts 611 karma points
    Apr 13, 2015 @ 15:15
    Matthew Kirschner
    0

    Hi, Rohan.

    Umbraco provides a macro snippet that should do most of the work, you just need to make it available.

    In the Umbraco Backoffice under the Developer section, right click on Partial View Macro Files and select Create. Give the new macro partial a name and select the Login snippet. This will create a new cshtml file in your solution with most of the login logic in place. You will now have to create a Macro that links to this file and takes a redirectUrl parameter of type Content Picker. Embed this macro into the richtext editor of any page and you now have your login for Public Access.

    To get this to work for me, I had to make a slight tweak to the login snippet. Add this underneath the declaration of loginModel:

        var loginUrlPart = Umbraco.Content(Model.Content.Id).Url;
        var currentUrl = Request.RawUrl;
    
        /**
         * This conditional redirect is necessary due to Umbraco's use of Public Access.
         * Rather than setting a query string redirect url, Umbraco alters the raw URL to be the referrer.
         * So, if the raw url is anything but the sign in page's url, then we redirect to the raw url.
         * Otherwise, use the macro parameter, redirectUrl.
         */
        // 
        // Rather than
        loginModel.RedirectUrl = currentUrl.Contains(loginUrlPart) ? 
            Umbraco.Content(Model.MacroParameters["redirectUrl"]).Url : 
            currentUrl;
    
  • Matthew Kirschner 323 posts 611 karma points
    Apr 13, 2015 @ 15:35
    Matthew Kirschner
    0

    Rohan, I think I missed a few steps here. Check out this other page that is discussing your issue in more detail: https://our.umbraco.org/forum/umbraco-7/using-umbraco-7/53836-Member-login-doesnt-redirect-to-protected-node-after-login?p=0#comment215926

  • Michael 22 posts 61 karma points
    May 26, 2015 @ 11:02
    Michael
    0

    I also encoutered this problem, I decide tol implement the mebership function via MVC, 

    @Dennis. The link you posted I don't have previlege to see the video. Is there any way I can watch the video?

     

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    May 26, 2015 @ 13:14
    Dennis Aaen
    0

    Hi Michael,

    Yes to be able to watch the video you need to subscribe to the Umbraco TV you can find the different plans here: http://umbraco.tv/plans-signup/

    /Dennis

Please Sign in or register to post replies

Write your reply to:

Draft