Created
August 3, 2017 09:23
-
-
Save DmitrySikorsky/9973f520223d09ee3416bfabe4ba2d13 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| @inject AspNetCoreCustomUserManager.IUserManager UserManager | |
| @using System.Security.Claims | |
| <h1>ASP.NET Core<br />Custom User Manager</h1> | |
| <div class="form__field field"> | |
| <span class="marker marker--secondary">User.Identity.IsAuthenticated:</span> @User.Identity.IsAuthenticated | |
| </div> | |
| @if (this.User.Identity.IsAuthenticated) | |
| { | |
| <div class="form__field field"> | |
| <span class="marker marker--secondary">UserManager.GetCurrentUser(this.Context).Name:</span> @UserManager.GetCurrentUser(this.Context).Name | |
| </div> | |
| <div class="form__field field"> | |
| <span class="marker marker--secondary">User.HasClaim(ClaimTypes.Role, "Administrator"):</span> @User.HasClaim(ClaimTypes.Role, "Administrator") | |
| </div> | |
| <div class="form__field field"> | |
| <span class="marker marker--secondary">User.HasClaim("Permission", "DoEverything"):</span> @User.HasClaim("Permission", "DoEverything") | |
| </div> | |
| } | |
| @if (this.User.Identity.IsAuthenticated) | |
| { | |
| <form class="form" action="/home/logout" method="post"> | |
| <div class="form__buttons buttons"> | |
| <button type="submit">Logout user</button> | |
| </div> | |
| </form> | |
| } | |
| else | |
| { | |
| <form class="form" action="/home/login" method="post"> | |
| <div class="form__buttons buttons"> | |
| <button type="submit">Login user</button> | |
| </div> | |
| </form> | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment