From d4b9d5f64b62495fe198883c67c78edb5ac9a6be Mon Sep 17 00:00:00 2001 From: Joseph Ortiz Date: Fri, 3 Oct 2025 10:26:06 -0700 Subject: [PATCH 1/7] Update database connection string in appsettings.json, changed DB name The `DefaultConnection` string in the `ConnectionStrings` section of the `appsettings.json` file was updated. The database name was changed --- SpeakingInBitsWeb/appsettings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SpeakingInBitsWeb/appsettings.json b/SpeakingInBitsWeb/appsettings.json index 116f639..1616867 100644 --- a/SpeakingInBitsWeb/appsettings.json +++ b/SpeakingInBitsWeb/appsettings.json @@ -1,6 +1,6 @@ { "ConnectionStrings": { - "DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=aspnet-SpeakingInBitsWeb-8268c9ba-1359-43cc-9195-54c9deec90b2;Trusted_Connection=True;MultipleActiveResultSets=true" + "DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=SpeakingInBitsDb;Trusted_Connection=True;MultipleActiveResultSets=true" }, "Logging": { "LogLevel": { From 5ec3f03ecd3ef7cd6955467717f4e4e379fc8aba Mon Sep 17 00:00:00 2001 From: Joseph Ortiz Date: Fri, 3 Oct 2025 10:41:19 -0700 Subject: [PATCH 2/7] Add ApplicationUser class for custom user data, it extends the default IdentityUser --- SpeakingInBitsWeb/Models/ApplicationUser.cs | 22 +++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 SpeakingInBitsWeb/Models/ApplicationUser.cs diff --git a/SpeakingInBitsWeb/Models/ApplicationUser.cs b/SpeakingInBitsWeb/Models/ApplicationUser.cs new file mode 100644 index 0000000..7d60de3 --- /dev/null +++ b/SpeakingInBitsWeb/Models/ApplicationUser.cs @@ -0,0 +1,22 @@ +using Microsoft.AspNetCore.Identity; + +namespace SpeakingInBitsWeb.Models +{ + /// + /// Represents a custom application user with additional profile information. + /// + /// Use this class to store and manage user-specific data beyond the default identity + /// fields. + public class ApplicationUser : IdentityUser + { + /// + /// The user's legal first name + /// + public required string FirstName { get; set; } + + /// + /// The user's legal last name + /// + public required string LastName { get; set; } + } +} From 699680e72a861d58ce63e55b23f16b859ee6ee6c Mon Sep 17 00:00:00 2001 From: Joseph Ortiz Date: Fri, 3 Oct 2025 10:49:27 -0700 Subject: [PATCH 3/7] Refactor Identity configuration to use custom ApplicationUser for identity management Updated ApplicationDbContext to use ApplicationUser instead of IdentityUser, enabling a custom user model. Modified Program.cs to configure identity services with ApplicationUser and ApplicationDbContext. Updated _LoginPartial.cshtml to use SignInManager and UserManager with ApplicationUser. --- SpeakingInBitsWeb/Data/ApplicationDbContext.cs | 3 ++- SpeakingInBitsWeb/Program.cs | 3 ++- SpeakingInBitsWeb/Views/Shared/_LoginPartial.cshtml | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/SpeakingInBitsWeb/Data/ApplicationDbContext.cs b/SpeakingInBitsWeb/Data/ApplicationDbContext.cs index bcd098e..0329da5 100644 --- a/SpeakingInBitsWeb/Data/ApplicationDbContext.cs +++ b/SpeakingInBitsWeb/Data/ApplicationDbContext.cs @@ -1,9 +1,10 @@ using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; +using SpeakingInBitsWeb.Models; namespace SpeakingInBitsWeb.Data { - public class ApplicationDbContext(DbContextOptions options) : IdentityDbContext(options) + public class ApplicationDbContext(DbContextOptions options) : IdentityDbContext(options) { } } diff --git a/SpeakingInBitsWeb/Program.cs b/SpeakingInBitsWeb/Program.cs index c7a4dff..fad9f1e 100644 --- a/SpeakingInBitsWeb/Program.cs +++ b/SpeakingInBitsWeb/Program.cs @@ -1,6 +1,7 @@ using Microsoft.AspNetCore.Identity; using Microsoft.EntityFrameworkCore; using SpeakingInBitsWeb.Data; +using SpeakingInBitsWeb.Models; var builder = WebApplication.CreateBuilder(args); @@ -10,7 +11,7 @@ options.UseSqlServer(connectionString)); builder.Services.AddDatabaseDeveloperPageExceptionFilter(); -builder.Services.AddDefaultIdentity(options => options.SignIn.RequireConfirmedAccount = true) +builder.Services.AddDefaultIdentity(options => options.SignIn.RequireConfirmedAccount = true) .AddEntityFrameworkStores(); builder.Services.AddControllersWithViews(); diff --git a/SpeakingInBitsWeb/Views/Shared/_LoginPartial.cshtml b/SpeakingInBitsWeb/Views/Shared/_LoginPartial.cshtml index 921dbe1..e3d30b0 100644 --- a/SpeakingInBitsWeb/Views/Shared/_LoginPartial.cshtml +++ b/SpeakingInBitsWeb/Views/Shared/_LoginPartial.cshtml @@ -1,6 +1,6 @@ @using Microsoft.AspNetCore.Identity -@inject SignInManager SignInManager -@inject UserManager UserManager +@inject SignInManager SignInManager +@inject UserManager UserManager