From bf0d629e55c87beae1d34db9133cfb9e2b724181 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Fri, 16 Oct 2020 20:31:23 +0300 Subject: [PATCH] Created ASP.NET Core MVC / Razor Pages UI: JavaScript CurrentUser API document --- .../AspNetCore/JavaScript-API/CurrentUser.md | 49 +++++++++++++++++++ docs/en/UI/AspNetCore/JavaScript-API/Index.md | 2 +- docs/en/docs-nav.json | 4 ++ 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 docs/en/UI/AspNetCore/JavaScript-API/CurrentUser.md diff --git a/docs/en/UI/AspNetCore/JavaScript-API/CurrentUser.md b/docs/en/UI/AspNetCore/JavaScript-API/CurrentUser.md new file mode 100644 index 0000000000..038bb9dff1 --- /dev/null +++ b/docs/en/UI/AspNetCore/JavaScript-API/CurrentUser.md @@ -0,0 +1,49 @@ +# 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](../../../CurrentUser.md) 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: + +````js +{ + 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"] +} +```` + +So, `abp.currentUser.userName` returns `john` in this case. + +## Anonymous User + +If the user was not authenticated, this object will be something like below: + +````js +{ + isAuthenticated: false, + id: null, + tenantId: null, + userName: null, + name: null, + surName: null, + email: null, + emailVerified: false, + phoneNumber: null, + phoneNumberVerified: false, + roles: [] +} +```` + +You can check `abp.currentUser.isAuthenticated` to understand if the use was authenticated or not. \ No newline at end of file diff --git a/docs/en/UI/AspNetCore/JavaScript-API/Index.md b/docs/en/UI/AspNetCore/JavaScript-API/Index.md index 38cde6217e..769fe548b6 100644 --- a/docs/en/UI/AspNetCore/JavaScript-API/Index.md +++ b/docs/en/UI/AspNetCore/JavaScript-API/Index.md @@ -6,7 +6,7 @@ ABP provides a set of JavaScript APIs for ASP.NET Core MVC / Razor Pages applica * [abp.ajax](Ajax.md) * [abp.auth](Auth.md) -* abp.currentUser +* [abp.currentUser](CurrentUser.md) * abp.dom * [abp.event](Events.md) * abp.features diff --git a/docs/en/docs-nav.json b/docs/en/docs-nav.json index 1ef289851d..955ab920b3 100644 --- a/docs/en/docs-nav.json +++ b/docs/en/docs-nav.json @@ -459,6 +459,10 @@ "text": "Auth", "path": "UI/AspNetCore/JavaScript-API/Auth.md" }, + { + "text": "Current User", + "path": "UI/AspNetCore/JavaScript-API/CurrentUser.md" + }, { "text": "Settings", "path": "UI/AspNetCore/JavaScript-API/Settings.md"