ASP.NET Core: Authentication

Menu
Menu

SignOut Authentication Pages

Adding a Signed In Message

In the template file Views/Shared/_CMS.cshtml add some conditional logic to display a logout message to logged in users. Note the use of User.Identity.IsAuthenticated.

PAGE: Pages/Shared/_CMS.cshtml

Building a Sign Out

Once logged in a cookie has been created to control authentication.

The Cookie named .AspNetCore.Identity.Application could be deleted to simulate a logout, however we'll add that functionality to our pages.

Tip:

The Cookie controlling the Identity framework can be renamed in Startup.cs in the options for the ConfigureApplicationCookie using an option value of Cookie.Name

Add an Action to the Controllers/SecurityController.cs to SignOut.

CONTROLLER: Controllers/SecurityController.cs

Save and test your application. You should be able to sign in and sign out. Once signed out the user is redirected.

Challenge:

Investigate changing password requirements.

Try adding additional information to the registration set up.

Investigate adding additional 'roles'.