Umbraco 8.2.2 - Get current user (not member) in front side website view/cshtml
Hello,
I am trying to either get the current Umbarco user (not member) in the front side of the website (inside a 'cshtm' view), or simply find if there is a User logged in.
I understand that around V.8 using services is the way to go, so I tried based on
IUserService userService = Services.UserService;
But I can't find a working way to find a user.
I tried a deep Google search and during many hours tried many other ways (some outdated or deprecated by now).
Umbraco 8.2.2 - Get current user (not member) in front side website view/cshtml
Hello,
I am trying to either get the current Umbarco user (not member) in the front side of the website (inside a 'cshtm' view), or simply find if there is a User logged in.
I understand that around V.8 using services is the way to go, so I tried based on
But I can't find a working way to find a user.
I tried a deep Google search and during many hours tried many other ways (some outdated or deprecated by now).
Surely there has to be a way...
Any help would be appreciated :)
Many thanks,
Rotem
I spent hours on this... for others and for future reference, here is the answer:
Make sure you use:
@using Umbraco.Web.Security
bool isLoggedin = new HttpContextWrapper(HttpContext.Current).GetUmbracoAuthTicket() != null;
Hi,
I've not had to do this myself but this seems to work.
I've no idea if it's the "proper" way.
Via RJ on https://our.umbraco.com/forum/umbraco-8/96524-show-content-for-backend-admin-only
EDIT: Cross posted with Rotem - he was first ;)
is working on a reply...