I have been trying to get current backend user and current member user logged in when they both are logged in but when ever the member is logged in the backend user is always returned as null.
I have tried few of the options I know that get the backend user, f.ex : UmbracoContext.Current.Security.CurrentUser,umbraco.BusinessLogic.User.GetCurrent() and umbraco.helper.GetCurrentUmbracoUser().
All return null when member is logged in.
I suspect that they are using the same authentication in the .net membership so the member always overrides the umbraco user.
Has anybody managed to get both users at the same time when they are logged in ?
That was my problem too. I found the way though. We can get current user by a method like this:
public static IUser GetCurrentUser() { var userName = new HttpContextWrapper(HttpContext.Current).GetUmbracoAuthTicket().Name; return ApplicationContext.Current.Services.UserService.GetByUsername(userName); }
You'll want some usings also:
using Umbraco.Core; using Umbraco.Core.Models.Membership; using Umbraco.Core.Security;
Get Backend User when member is logged in
Hi,
I have been trying to get current backend user and current member user logged in when they both are logged in but when ever the member is logged in the backend user is always returned as null.
I have tried few of the options I know that get the backend user, f.ex : UmbracoContext.Current.Security.CurrentUser,umbraco.BusinessLogic.User.GetCurrent() and umbraco.helper.GetCurrentUmbracoUser().
All return null when member is logged in.
I suspect that they are using the same authentication in the .net membership so the member always overrides the umbraco user.
Has anybody managed to get both users at the same time when they are logged in ?
Hi Garðar,
What version of Umbraco are you using? Both use different membership providers.
You should be able to get the current Member by using
Membership.GetUser()
.You should be able to get the current back office User by using
UmbracoContext.Security.CurrentUser
:Hope that helps.
Thanks, Dan.
That was my problem too. I found the way though. We can get current user by a method like this:
You'll want some usings also:
is working on a reply...