Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hello
In umbraco 8 there was a way of determining if a user was logged in on the frontend of a website by using “GetUmbracoAuthTicket” https://our.umbraco.com/forum/using-umbraco-and-getting-started/105929-umbraco-8-can-i-check-if-a-user-is-logged-in-within-a-razor-view (maybe an "unofficial" way but it worked)
That doesn’t exist in umbraco 9 so I wondered if anyone has a technique for checking there is a logged in user? (i.e. backoffice user, not member)
Thanks
I think what you are looking for is the Member Manager.
If in razor, you can use DI to get a reference to the member manager. Then you would use the IsLoggedIn method.
IsLoggedIn
@inject IMemberManager _memberManager; // other code _memberManager.IsLoggedIn()
*Note that the page I linked to has a few examples of how to do other things - like check page permissions, and get the currently signed in member.
thanks for the reply Mark, but im after something that tells me if a backoffice user is logged in, not a website member
Hi Andrew
Take a look at this post. I haven't tried it myself, but it seems it should work: https://our.umbraco.com/forum/umbraco-9/106857-how-do-i-determine-if-a-backoffice-user-is-logged-in-from-a-razor-view#comment-334423
Sorry, it's 2am. :)
There's a tag helper that can be installed to help you render some content based on the currently signed in member or user, even tailor it down to what groups they are assigned.
Here is the code that you need to clone in your own project if you'd rather not install the rest of the tag helper package.
thanks for the info Bjarne and Mark :)
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Umbraco 9 Can I check if a user is logged in within a razor view?
Hello
In umbraco 8 there was a way of determining if a user was logged in on the frontend of a website by using “GetUmbracoAuthTicket” https://our.umbraco.com/forum/using-umbraco-and-getting-started/105929-umbraco-8-can-i-check-if-a-user-is-logged-in-within-a-razor-view (maybe an "unofficial" way but it worked)
That doesn’t exist in umbraco 9 so I wondered if anyone has a technique for checking there is a logged in user? (i.e. backoffice user, not member)
Thanks
I think what you are looking for is the Member Manager.
If in razor, you can use DI to get a reference to the member manager. Then you would use the
IsLoggedIn
method.*Note that the page I linked to has a few examples of how to do other things - like check page permissions, and get the currently signed in member.
thanks for the reply Mark, but im after something that tells me if a backoffice user is logged in, not a website member
Hi Andrew
Take a look at this post. I haven't tried it myself, but it seems it should work: https://our.umbraco.com/forum/umbraco-9/106857-how-do-i-determine-if-a-backoffice-user-is-logged-in-from-a-razor-view#comment-334423
Sorry, it's 2am. :)
There's a tag helper that can be installed to help you render some content based on the currently signed in member or user, even tailor it down to what groups they are assigned.
Here is the code that you need to clone in your own project if you'd rather not install the rest of the tag helper package.
thanks for the info Bjarne and Mark :)
is working on a reply...