Copied to clipboard

Flag this post as spam?

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


  • andrew shearer 409 posts 517 karma points
    Oct 07, 2011 @ 04:04
    andrew shearer
    0

    determine if cms user is logged on from within website page?

    what is the best way of doing this? via the default UsersMembershipProvider?

    I'd like to add a special admin section to a website page template which is visible when there is a current cms backoffice user logged on.

    thanks

     

  • Markus Johansson 1701 posts 4879 karma points c-trib
    Oct 07, 2011 @ 08:12
    Markus Johansson
    0

    I think you can use the same classes as if you ifyou where building a custom section in the backoffice?

  • Rodion Novoselov 694 posts 859 karma points
    Oct 07, 2011 @ 08:31
    Rodion Novoselov
    0

    Hi. I suppose that the usual 'LoginView' control (http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.loginview.aspx) should work well for this case, since umbraco authentication is based on the stadard asp.net membership and role management.

  • Markus Johansson 1701 posts 4879 karma points c-trib
    Oct 07, 2011 @ 11:52
    Markus Johansson
    0

    Are we talking Umbraco backoffice users or site members?

    The default membership-provider looks at members so the LoginView (and other) won't work if you want to handle loggedin backend users. You could probably change that in your configuration.

  • Rodion Novoselov 694 posts 859 karma points
    Oct 07, 2011 @ 14:06
    Rodion Novoselov
    0

    Actually, I realized that Umbraco uses some custom approach to authentication of cms users (not members). So that to be exact you cannot at all have a cms user 'logged in' to the site (i.e. the site itself, not the /umbraco/* area).

    Could you explain in more details what scenario you imply?

  • Tom Fulton 2030 posts 4996 karma points c-trib
    Oct 07, 2011 @ 14:27
    Tom Fulton
    0

    You could maybe try testing for:  umbraco.BusinessLogic.User.GetCurrent() != null

    -Tom

  • andrew shearer 409 posts 517 karma points
    Oct 09, 2011 @ 21:51
    andrew shearer
    0

     

    hi Tom, yes i had tried User.GetCurrent() but it didn't work. I guess a normal website page doesn't inherit from the same thing as a CMS page and therefore doesn't have the right context?

    Rodion, my aim is to have a section on each site page that provides a shortcut into the cms using:

    /umbraco/actions/editContent.aspx?id=[nodeid]

    i wanted to use a condition to make this only visible to admin users (maybe others too).

     

    thanks

     


     

     

  • Rodion Novoselov 694 posts 859 karma points
    Oct 09, 2011 @ 23:04
    Rodion Novoselov
    0

    Andrew, so you will have to provide some means of authentication for a user visiting a site page (not a backoffice page). So, how are you going to implement this? It does matter since authentication of a backoffice user goes some different way (for example it uses different auth coockie).

  • andrew shearer 409 posts 517 karma points
    Oct 09, 2011 @ 23:06
    andrew shearer
    0

    i was just going to work on the basis that once the user has logged into the backoffice as normal then my proposed section would appear on the site,

  • jaygreasley 416 posts 403 karma points
    Oct 09, 2011 @ 23:45
    jaygreasley
    0

    I may have the worng end of the stick but is what you actually want something like Canvas mode?

  • Rodion Novoselov 694 posts 859 karma points
    Oct 10, 2011 @ 00:06
    Rodion Novoselov
    0

    Ok, Andrew, this razor snippet should work:

    @if(umbraco.BusinessLogic.User.GetCurrent() != null) {
       <a href="/umbraco/actions/[email protected]">Edit content</a>
    }

     

  • Tom Fulton 2030 posts 4996 karma points c-trib
    Oct 10, 2011 @ 13:57
    Tom Fulton
    0

    Didn't realize you were doing this from a non-Umbraco page.  I think you can inherit somehow from the umbracoPage class which might allow you to use the above, not sure if that's an option for you or not though.

    As a long-winded solution you could setup a /base/ call like /base/user/IsLoggedOn that returns true/false that you can call from your custom page - this way the code would be running in the umbraco context.  Or perhaps you can use appbase to set a cookie when the user logs in and check the cookie from your custom page?

  • andrew shearer 409 posts 517 karma points
    Oct 10, 2011 @ 21:32
    andrew shearer
    0

    hi Tom, yep the IsLoggedOn call seems like the most appropriate option.thanks

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies