You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 10, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: docs/4. Add auth features.md
+20-13Lines changed: 20 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,12 +30,6 @@ In this module we're going to add the capability for users to register and sign-
30
30
## Organize the newly created files
31
31
> Note the new files added to the project in the "Areas/Identity" folder. We're going to clean these up a little to better match this project's conventions.
32
32
33
-
1. Staying in `IdentityHostingStartup.cs`, add a call to configure the Identity UI to use Bootstrap 4:
34
-
```csharp
35
-
services.AddDefaultIdentity<User>()
36
-
.AddDefaultUI(UIFramework.Bootstrap4)
37
-
.AddEntityFrameworkStores<IdentityDbContext>();
38
-
```
39
33
1. Delete the `_ValidationScriptsPartial.cshtml` file in the `/Areas/Identity/Pages` folder, as we already have one in our project's regular pages folder.
40
34
1. Delete the `ScaffoldingReadme.txt` file.
41
35
@@ -69,10 +63,25 @@ In this module we're going to add the capability for users to register and sign-
69
63
```
70
64
71
65
### Generate the Entity Framework migration for our Identity schema
72
-
>Nowthatwe've modified the Identity model, we need to create the Entity Framework migration to create the matching database schema
1. In Visual Studio, select the Tools -> NuGet Package Manager -> Package Manager Console
70
+
71
+
1. Run the following commands in the Package Manager Console
72
+
```console
73
+
Add-Migration CreateIdentitySchema
74
+
Update-Database
75
+
```
76
+
77
+
#### Command line
78
+
79
+
1. Run the following commands in the command prompt:
80
+
```console
81
+
dotnet build
82
+
dotnet ef migrations add CreateIdentitySchema
83
+
dotnet ef database update
84
+
```
76
85
77
86
### Add the authentication middleware
78
87
> We need to ensure that the request pipeline contains the Authentication middleware before any other middleware that represents resources we want to potentially authorize, e.g. Razor Pages
@@ -110,7 +119,6 @@ In this module we're going to add the capability for users to register and sign-
110
119
> Let's make it so the site allows creation of an admin user when there isn't one already. The first user to access the site will be deemed the administrator.
111
120
112
121
1. Create a new class `AdminService` in the `Services` folder. This class will be responsible for managing the creation key generation and tracking whether the site should allow creating admin users.
113
-
1. Add code to the class that will create an appropriately long creation key and expose it via a property:
114
122
``` c#
115
123
public class AdminService
116
124
{
@@ -156,7 +164,7 @@ In this module we're going to add the capability for users to register and sign-
>WenowneedtooverridethedefaultRegisterpagetoaddUIfor accepting the admin creation key and verifying it when processing the request
167
+
> We now need to override the default Register page to enable creating the admin account when the first user is registered.
160
168
161
169
1. Run the Identity scaffolder again, but this time select the `Account\Register` page in the list of files to override and select the `IdentityDbContext (FrontEnd.Data)`
162
170
* On command line, run
@@ -329,7 +337,6 @@ In this module we're going to add the capability for users to register and sign-
329
337
1. Register the custom `UserClaimsPrincipalFactory<User>` in the `IdentityHostingStartup` class:
0 commit comments