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.
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?
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).
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).
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?
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
I think you can use the same classes as if you ifyou where building a custom section in the backoffice?
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.
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.
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?
You could maybe try testing for: umbraco.BusinessLogic.User.GetCurrent() != null
-Tom
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
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).
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,
I may have the worng end of the stick but is what you actually want something like Canvas mode?
Ok, Andrew, this razor snippet should work:
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?
hi Tom, yep the IsLoggedOn call seems like the most appropriate option.thanks
is working on a reply...