ASP.NET Core MVC / Razor Pages UI: JavaScript CurrentUser API

abp.currentUser is an object that contains information about the current user of the application.

This document only explains the JavaScript API. See the CurrentUser document to get information about the current user in the server side.

Authenticated User

If the user was authenticated, this object will be something like below:

{
  isAuthenticated: true,
  id: "34f1f4a7-13cc-4b91-84d1-b91c87afa95f",
  tenantId: null,
  userName: "john",
  name: "John",
  surName: "Nash",
  email: "john.nash@abp.io",
  emailVerified: true,
  phoneNumber: null,
  phoneNumberVerified: false,
  roles: ["moderator","supporter"]
}
JavaScript

So, abp.currentUser.userName returns john in this case.

Anonymous User

If the user was not authenticated, this object will be something like below:

{
  isAuthenticated: false,
  id: null,
  tenantId: null,
  userName: null,
  name: null,
  surName: null,
  email: null,
  emailVerified: false,
  phoneNumber: null,
  phoneNumberVerified: false,
  roles: []
}
JavaScript

You can check abp.currentUser.isAuthenticated to understand if the use was authenticated or not.

Contributors


Last updated: July 31, 2024 Edit this page on GitHub

Was this page helpful?

Please make a selection.

To help us improve, please share your reason for the negative feedback in the field below.

Please enter a note.

Thank you for your valuable feedback!

Please note that although we cannot respond to feedback, our team will use your comments to improve the experience.

Community Talks

Real World Problems and Solutions with AI

27 Feb, 17:00
Online
Watch the Event
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
Do you need assistance from an ABP expert?
Schedule a Meeting
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book