-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
43 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
Example1.RazorPages.IndividualAccounts/Pages/UserClaims.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
@page | ||
@model UserClaimsModel | ||
|
||
<p>Current logged in user claims.</p> | ||
|
||
@if (Model.ThisUser?.Identity.IsAuthenticated == true) | ||
{ | ||
<h4>User '@User.Identity.Name'</h4> | ||
<ul> | ||
|
||
@foreach (var claim in @Model.ThisUser.Claims) | ||
{ | ||
<li>@claim.ToString()</li> | ||
} | ||
</ul> | ||
} | ||
else | ||
{ | ||
<h4>No user is logged in.</h4> | ||
} |
16 changes: 16 additions & 0 deletions
16
Example1.RazorPages.IndividualAccounts/Pages/UserClaims.cshtml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System.Security.Claims; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.RazorPages; | ||
|
||
namespace Example1.RazorPages.IndividualAccounts.Pages | ||
{ | ||
public class UserClaimsModel : PageModel | ||
{ | ||
public ClaimsPrincipal ThisUser { get; set; } | ||
|
||
public void OnGet() | ||
{ | ||
ThisUser = User; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters