How can I know the current User ID, User Email, or User Name for Umbraco Backoffice User Login?
Hi Everyone,
I need to know the information of the current Umbraco back office user is logging in, I need to know the group information indeed.
Now, I can know only, whether user is logging in or not. But, I don't know any other information of this user:
var ticket = new HttpContextWrapper(HttpContext.Current).GetUmbracoAuthTicket();
bool userLoggedIn = ticket != null;
I've an example code to retrieve a group information already. But, I don't know any information for current logging in user, such as email, id, or name to retrieve a group information from them.
I use these code to retrieve a user information including group information :
var umUser = Current.UmbracoContext.Security.CurrentUser;
> Compiler Error Message: CS0103: The name 'Current' does not exist in the current context
and
var contextReference = _contextFactory.EnsureUmbracoContext();
var umUser = contextReference.UmbracoContext.Security.CurrentUser;
> Compiler Error Message: CS0103: The name '_contextFactory' does not exist in the current context
I used it in .cshtml file. How can I reference to contextFactory or Current context. I use Umbraco version 8.6.3.
Could you show me an example for only display the current username that logging in umbraco Backoffice. Look like this:
@inherits Umbraco.Web.Mvc.UmbracoViewPage
@using Umbraco.Web.Security
@{
var ticket = new HttpContextWrapper(HttpContext.Current).GetUmbracoAuthTicket();
bool userLoggedIn = ticket != null;
//var umUser = Current.UmbracoContext.Security.CurrentUser;
var contextReference = _contextFactory.EnsureUmbracoContext();
var umUser = contextReference.UmbracoContext.Security.CurrentUser;
}
Logged in = @userLoggedIn<br>
Username = @umUser<br>
How can I know the current User ID, User Email, or User Name for Umbraco Backoffice User Login?
Hi Everyone,
I need to know the information of the current Umbraco back office user is logging in, I need to know the group information indeed.
Now, I can know only, whether user is logging in or not. But, I don't know any other information of this user:
I've an example code to retrieve a group information already. But, I don't know any information for current logging in user, such as email, id, or name to retrieve a group information from them.
I use these code to retrieve a user information including group information :
https://our.umbraco.com/Documentation/Reference/Management/Services/UserService/Get-a-reference-to-a-user
But, it needs Id, Username, or Email of the user. So, how can I known the current Umbraco back office that logging in.
Thank you
You can access the current backoffice user with:
Or with:
Thanks for your reply. But, I got an error.
and
I used it in .cshtml file. How can I reference to contextFactory or Current context. I use Umbraco version 8.6.3.
Could you show me an example for only display the current username that logging in umbraco Backoffice. Look like this:
Thanks a lot.
@Vanlop Incham i got the same error iam using umbraco 12
is working on a reply...