MVC Blog: Claims II - How to make an Admin


Garry West
09/16/2024

So now we restrict the create, update, delete operations to users with the claim of IsAdmin.

Here's how I set myself to admin automatically. In appsettings.json :

In Areas/Identity/Pages/Account/ConfirmEmail.cshtml.cs:

Change OnGetAsync to add the claim:

If I add my defined admin user with the email from appsettings, I can now see and use everything again:

blog , identity