 b24beb3154
			
		
	
	
		b24beb3154
		
	
	
	
	
		
			
			This commit integrates ASP.NET Core Identity into the application to enable user registration, login, and management. This lays the groundwork for securing data per user.
**Key Changes:**
*   **DbContext Configuration:**
    *   Modified `ApplicationDbContext.cs` to inherit from `IdentityDbContext<IdentityUser>`.
    *   Removed an unnecessary `using` statement from `ApplicationDbContext.cs`.
*   **Program.cs Setup:**
    *   Configured `AddDefaultIdentity<IdentityUser>` with `AddEntityFrameworkStores<ApplicationDbContext>()` to register Identity services.
    *   Ensured correct ordering of `UseAuthentication()` and `UseAuthorization()` middleware.
    *   Added `app.MapRazorPages()` to enable the Identity UI pages.
    *   Verified core package versions in `turf_tasker.csproj` for consistency across EF Core and Identity components (`8.0.6`).
*   **Identity UI:**
    *   Scaffolded ASP.NET Core Identity pages (Login, Register, Manage, etc.) to provide the user interface for authentication.
    *   Added a `_LoginPartial.cshtml` partial view to the `Views/Shared` folder.
    *   Rendered `_LoginPartial` in `Views/Shared/_Layout.cshtml` to display login/register/logout links in the navigation bar.
*   **Migrations:**
    *   Created and applied a new migration (`AddIdentitySchema`) to create the necessary ASP.NET Core Identity database tables (e.g., `AspNetUsers`, `AspNetRoles`).
		
	
			
		
			
				
	
	
		
			44 lines
		
	
	
	
		
			2 KiB
		
	
	
	
		
			Text
		
	
	
	
	
	
			
		
		
	
	
			44 lines
		
	
	
	
		
			2 KiB
		
	
	
	
		
			Text
		
	
	
	
	
	
| @page
 | |
| @model EmailModel
 | |
| @{
 | |
|     ViewData["Title"] = "Manage Email";
 | |
|     ViewData["ActivePage"] = ManageNavPages.Email;
 | |
| }
 | |
| 
 | |
| <h3>@ViewData["Title"]</h3>
 | |
| <partial name="_StatusMessage" for="StatusMessage" />
 | |
| <div class="row">
 | |
|     <div class="col-md-6">
 | |
|         <form id="email-form" method="post">
 | |
|             <div asp-validation-summary="All" class="text-danger" role="alert"></div>
 | |
|             @if (Model.IsEmailConfirmed)
 | |
|             {
 | |
|                 <div class="form-floating mb-3 input-group">
 | |
|                     <input asp-for="Email" class="form-control" placeholder="Please enter your email." disabled />
 | |
|                         <div class="input-group-append">
 | |
|                             <span class="h-100 input-group-text text-success font-weight-bold">✓</span>
 | |
|                         </div>
 | |
|                     <label asp-for="Email" class="form-label"></label>
 | |
|                 </div>
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 <div class="form-floating mb-3">
 | |
|                     <input asp-for="Email" class="form-control" placeholder="Please enter your email." disabled />
 | |
|                     <label asp-for="Email" class="form-label"></label>
 | |
|                     <button id="email-verification" type="submit" asp-page-handler="SendVerificationEmail" class="btn btn-link">Send verification email</button>
 | |
|                 </div>
 | |
|             }
 | |
|             <div class="form-floating mb-3">
 | |
|                 <input asp-for="Input.NewEmail" class="form-control" autocomplete="email" aria-required="true" placeholder="Please enter new email." />
 | |
|                 <label asp-for="Input.NewEmail" class="form-label"></label>
 | |
|                 <span asp-validation-for="Input.NewEmail" class="text-danger"></span>
 | |
|             </div>
 | |
|             <button id="change-email-button" type="submit" asp-page-handler="ChangeEmail" class="w-100 btn btn-lg btn-primary">Change email</button>
 | |
|         </form>
 | |
|     </div>
 | |
| </div>
 | |
| 
 | |
| @section Scripts {
 | |
|     <partial name="_ValidationScriptsPartial" />
 | |
| }
 |