Skip to content
This repository has been archived by the owner on May 11, 2023. It is now read-only.

Commit

Permalink
Merge branch 'chap19-updates' of https://github.com/LaunchCodeEducati…
Browse files Browse the repository at this point in the history
…on/csharp-web-development into chap19-updates
  • Loading branch information
gildedgardenia committed Nov 18, 2022
2 parents 866cf07 + 32e9767 commit 1cc405d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/chapters/auth/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Earlier you may have added the following:
options.Password.RequireNonAlphanumeric = false;
options.Password.RequireUppercase = true;
options.Password.RequireLowercase = false;
}).AddEntityFrameworkStores<JobDbContext>();
}).AddEntityFrameworkStores<EventDbContext>();

This code is dictating the settings for account creation. Right now, for a user to create an account, they have to have the following:

Expand All @@ -47,7 +47,7 @@ The following is not true for a user to create an account.
#. Their password does not have to include lowercase letters.

These are just some basic requirements that can be changed to suit the needs of your application.
For a full list of the default settings for users' passwords and how we can change those settings, check out the `documentation <https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.identity.passwordoptions?view=aspnetcore-3.1>`__.
For a full list of the default settings for users' passwords and how we can change those settings, check out the `documentation <https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.identity.passwordoptions?view=aspnetcore-6.0>`__.

In ``ConfigureServices()``, we can also configure cookie settings, password hashers, user validation requirements, sign in settings and more.

Expand All @@ -68,4 +68,4 @@ Here are some examples of what you can do with it.
If you want to customize user data, it is best to do so when initially scaffolding the app.
`IdentityUser <https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.identity.entityframeworkcore.identityuser?view=aspnetcore-1.1>`__ has a number of properties that are important and relevant to storing user data.
However, when you read through the requirements you may notice that you need additional properties, such as the user's first and last name.
If you want to add custom properties, check out this `article <https://docs.microsoft.com/en-us/aspnet/core/security/authentication/add-user-data?view=aspnetcore-5.0&tabs=visual-studio>`__ from Microsoft.
If you want to add custom properties, check out this `article <https://learn.microsoft.com/en-us/aspnet/core/security/authentication/add-user-data?view=aspnetcore-6.0&tabs=visual-studio>`__ from Microsoft.
10 changes: 5 additions & 5 deletions src/chapters/auth/scaffolding.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ If the .NET Core SDK listed on line 2 does not match the SDK specified in your `

.. admonition:: Note

If you are do not have a ``global.json`` file, but the .NET Core SDK is still not matching your ``csproj`` file, you can create a new ``global.json`` file with the following command:
If you do not have a ``global.json`` file, but the .NET Core SDK is still not matching your ``csproj`` file, you can create a new ``global.json`` file with the following command:

::

Expand Down Expand Up @@ -181,7 +181,7 @@ In order to use Identity, we need to change what ``EventDbContext`` extends. Cur

.. sourcecode:: csharp

public class JobDbContext: IdentityDbContext<IdentityUser, IdentityRole, string>
public class EventDbContext: IdentityDbContext<IdentityUser, IdentityRole, string>

We also need to add an additional line to ``OnModelCreating()``:

Expand Down Expand Up @@ -238,7 +238,7 @@ Add a line to ``ConfigureServices()`` in ``Startup.cs`` for the use of the Razor

var serverVersion = new MySqlServerVersion(new Version(8, 0, 29));
var defaultConnection = Configuration.GetConnectionString("DefaultConnection");
services.AddDbContext<JobDbContext>(options =>
services.AddDbContext<EventDbContext>(options =>
options.UseMySql(defaultConnection, serverVersion));

services.AddDefaultIdentity<IdentityUser>
Expand All @@ -250,7 +250,7 @@ Add a line to ``ConfigureServices()`` in ``Startup.cs`` for the use of the Razor
options.Password.RequireNonAlphanumeric = false;
options.Password.RequireUppercase = true;
options.Password.RequireLowercase = false;
}).AddEntityFrameworkStores<JobDbContext>();
}).AddEntityFrameworkStores<EventDbContext>();

Review ``Configure()`` in ``Startup.cs``. Above ``app.UseAuthorization()``, add one line of code like so:

Expand All @@ -259,7 +259,7 @@ Review ``Configure()`` in ``Startup.cs``. Above ``app.UseAuthorization()``, add
app.UseAuthentication();
app.UseAuthorization();

Add an additional line to ``app.UseEndpoints()`` inside of ``Configure()`` in ``Startup.cs``:
Add 2 additional lines to ``app.UseEndpoints()`` inside of ``Configure()`` in ``Startup.cs``:

.. sourcecode:: csharp
:lineno-start: 62
Expand Down

0 comments on commit 1cc405d

Please sign in to comment.