-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
31fabde
commit bcbd40b
Showing
403 changed files
with
21,054 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using Microsoft.AspNetCore.Identity; | ||
using Microsoft.AspNetCore.Identity.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace demoMvcCore.Areas.Identity.Data; | ||
|
||
public class AccounIdentityContext : IdentityDbContext<IdentityUser> | ||
{ | ||
public AccounIdentityContext(DbContextOptions<AccounIdentityContext> options) | ||
: base(options) | ||
{ | ||
} | ||
|
||
protected override void OnModelCreating(ModelBuilder builder) | ||
{ | ||
base.OnModelCreating(builder); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
@page | ||
@model AccessDeniedModel | ||
@{ | ||
ViewData["Title"] = "Access denied"; | ||
} | ||
|
||
<header> | ||
<h1 class="text-danger">@ViewData["Title"]</h1> | ||
<p class="text-danger">You do not have access to this resource.</p> | ||
</header> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
#nullable disable | ||
|
||
using Microsoft.AspNetCore.Mvc.RazorPages; | ||
|
||
namespace demoMvcCore.Areas.Identity.Pages.Account | ||
{ | ||
/// <summary> | ||
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used | ||
/// directly from your code. This API may change or be removed in future releases. | ||
/// </summary> | ||
public class AccessDeniedModel : PageModel | ||
{ | ||
/// <summary> | ||
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used | ||
/// directly from your code. This API may change or be removed in future releases. | ||
/// </summary> | ||
public void OnGet() | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
@page | ||
@model ConfirmEmailModel | ||
@{ | ||
ViewData["Title"] = "Confirm email"; | ||
} | ||
|
||
<h1>@ViewData["Title"]</h1> | ||
<partial name="_StatusMessage" model="Model.StatusMessage" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
#nullable disable | ||
|
||
using System; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Identity; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.RazorPages; | ||
using Microsoft.AspNetCore.WebUtilities; | ||
|
||
namespace demoMvcCore.Areas.Identity.Pages.Account | ||
{ | ||
public class ConfirmEmailModel : PageModel | ||
{ | ||
private readonly UserManager<IdentityUser> _userManager; | ||
|
||
public ConfirmEmailModel(UserManager<IdentityUser> userManager) | ||
{ | ||
_userManager = userManager; | ||
} | ||
|
||
/// <summary> | ||
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used | ||
/// directly from your code. This API may change or be removed in future releases. | ||
/// </summary> | ||
[TempData] | ||
public string StatusMessage { get; set; } | ||
public async Task<IActionResult> OnGetAsync(string userId, string code) | ||
{ | ||
if (userId == null || code == null) | ||
{ | ||
return RedirectToPage("/Index"); | ||
} | ||
|
||
var user = await _userManager.FindByIdAsync(userId); | ||
if (user == null) | ||
{ | ||
return NotFound($"Unable to load user with ID '{userId}'."); | ||
} | ||
|
||
code = Encoding.UTF8.GetString(WebEncoders.Base64UrlDecode(code)); | ||
var result = await _userManager.ConfirmEmailAsync(user, code); | ||
StatusMessage = result.Succeeded ? "Thank you for confirming your email." : "Error confirming your email."; | ||
return Page(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
@page | ||
@model ConfirmEmailChangeModel | ||
@{ | ||
ViewData["Title"] = "Confirm email change"; | ||
} | ||
|
||
<h1>@ViewData["Title"]</h1> | ||
<partial name="_StatusMessage" model="Model.StatusMessage" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
#nullable disable | ||
|
||
using System; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Identity; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.RazorPages; | ||
using Microsoft.AspNetCore.WebUtilities; | ||
|
||
namespace demoMvcCore.Areas.Identity.Pages.Account | ||
{ | ||
public class ConfirmEmailChangeModel : PageModel | ||
{ | ||
private readonly UserManager<IdentityUser> _userManager; | ||
private readonly SignInManager<IdentityUser> _signInManager; | ||
|
||
public ConfirmEmailChangeModel(UserManager<IdentityUser> userManager, SignInManager<IdentityUser> signInManager) | ||
{ | ||
_userManager = userManager; | ||
_signInManager = signInManager; | ||
} | ||
|
||
/// <summary> | ||
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used | ||
/// directly from your code. This API may change or be removed in future releases. | ||
/// </summary> | ||
[TempData] | ||
public string StatusMessage { get; set; } | ||
|
||
public async Task<IActionResult> OnGetAsync(string userId, string email, string code) | ||
{ | ||
if (userId == null || email == null || code == null) | ||
{ | ||
return RedirectToPage("/Index"); | ||
} | ||
|
||
var user = await _userManager.FindByIdAsync(userId); | ||
if (user == null) | ||
{ | ||
return NotFound($"Unable to load user with ID '{userId}'."); | ||
} | ||
|
||
code = Encoding.UTF8.GetString(WebEncoders.Base64UrlDecode(code)); | ||
var result = await _userManager.ChangeEmailAsync(user, email, code); | ||
if (!result.Succeeded) | ||
{ | ||
StatusMessage = "Error changing email."; | ||
return Page(); | ||
} | ||
|
||
// In our UI email and user name are one and the same, so when we update the email | ||
// we need to update the user name. | ||
var setUserNameResult = await _userManager.SetUserNameAsync(user, email); | ||
if (!setUserNameResult.Succeeded) | ||
{ | ||
StatusMessage = "Error changing user name."; | ||
return Page(); | ||
} | ||
|
||
await _signInManager.RefreshSignInAsync(user); | ||
StatusMessage = "Thank you for confirming your email change."; | ||
return Page(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
@page | ||
@model ExternalLoginModel | ||
@{ | ||
ViewData["Title"] = "Register"; | ||
} | ||
|
||
<h1>@ViewData["Title"]</h1> | ||
<h2 id="external-login-title">Associate your @Model.ProviderDisplayName account.</h2> | ||
<hr /> | ||
|
||
<p id="external-login-description" class="text-info"> | ||
You've successfully authenticated with <strong>@Model.ProviderDisplayName</strong>. | ||
Please enter an email address for this site below and click the Register button to finish | ||
logging in. | ||
</p> | ||
|
||
<div class="row"> | ||
<div class="col-md-4"> | ||
<form asp-page-handler="Confirmation" asp-route-returnUrl="@Model.ReturnUrl" method="post"> | ||
<div asp-validation-summary="ModelOnly" class="text-danger" role="alert"></div> | ||
<div class="form-floating mb-3"> | ||
<input asp-for="Input.Email" class="form-control" autocomplete="email" placeholder="Please enter your email."/> | ||
<label asp-for="Input.Email" class="form-label"></label> | ||
<span asp-validation-for="Input.Email" class="text-danger"></span> | ||
</div> | ||
<button type="submit" class="w-100 btn btn-lg btn-primary">Register</button> | ||
</form> | ||
</div> | ||
</div> | ||
|
||
@section Scripts { | ||
<partial name="_ValidationScriptsPartial" /> | ||
} |
Oops, something went wrong.