-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Bootstrap5 #33592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Bootstrap5 #33592
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
src/Identity/UI/src/Areas/Identity/Pages/V5/Account/AccessDenied.cshtml
This file contains hidden or 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> |
22 changes: 22 additions & 0 deletions
22
src/Identity/UI/src/Areas/Identity/Pages/V5/Account/AccessDenied.cshtml.cs
This file contains hidden or 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,22 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using Microsoft.AspNetCore.Mvc.RazorPages; | ||
|
||
namespace Microsoft.AspNetCore.Identity.UI.V4.Pages.Account.Internal | ||
{ | ||
/// <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() | ||
{ | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/Identity/UI/src/Areas/Identity/Pages/V5/Account/ConfirmEmail.cshtml
This file contains hidden or 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" /> |
64 changes: 64 additions & 0 deletions
64
src/Identity/UI/src/Areas/Identity/Pages/V5/Account/ConfirmEmail.cshtml.cs
This file contains hidden or 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,64 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.RazorPages; | ||
using Microsoft.AspNetCore.WebUtilities; | ||
|
||
namespace Microsoft.AspNetCore.Identity.UI.V4.Pages.Account.Internal | ||
{ | ||
/// <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> | ||
[AllowAnonymous] | ||
[IdentityDefaultUI(typeof(ConfirmEmailModel<>))] | ||
public abstract class ConfirmEmailModel : 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> | ||
[TempData] | ||
public string StatusMessage { get; set; } | ||
|
||
/// <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 virtual Task<IActionResult> OnGetAsync(string userId, string code) => throw new NotImplementedException(); | ||
} | ||
|
||
internal class ConfirmEmailModel<TUser> : ConfirmEmailModel where TUser : class | ||
{ | ||
private readonly UserManager<TUser> _userManager; | ||
|
||
public ConfirmEmailModel(UserManager<TUser> userManager) | ||
{ | ||
_userManager = userManager; | ||
} | ||
|
||
public override 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(); | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/Identity/UI/src/Areas/Identity/Pages/V5/Account/ConfirmEmailChange.cshtml
This file contains hidden or 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" /> |
82 changes: 82 additions & 0 deletions
82
src/Identity/UI/src/Areas/Identity/Pages/V5/Account/ConfirmEmailChange.cshtml.cs
This file contains hidden or 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,82 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.RazorPages; | ||
using Microsoft.AspNetCore.WebUtilities; | ||
|
||
namespace Microsoft.AspNetCore.Identity.UI.V4.Pages.Account.Internal | ||
{ | ||
/// <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> | ||
[AllowAnonymous] | ||
[IdentityDefaultUI(typeof(ConfirmEmailChangeModel<>))] | ||
public abstract class ConfirmEmailChangeModel : 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> | ||
[TempData] | ||
public string StatusMessage { get; set; } | ||
|
||
/// <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 virtual Task<IActionResult> OnGetAsync(string userId, string email, string code) => throw new NotImplementedException(); | ||
} | ||
|
||
internal class ConfirmEmailChangeModel<TUser> : ConfirmEmailChangeModel where TUser : class | ||
{ | ||
private readonly UserManager<TUser> _userManager; | ||
private readonly SignInManager<TUser> _signInManager; | ||
|
||
public ConfirmEmailChangeModel(UserManager<TUser> userManager, SignInManager<TUser> signInManager) | ||
{ | ||
_userManager = userManager; | ||
_signInManager = signInManager; | ||
} | ||
|
||
public override 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(); | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/Identity/UI/src/Areas/Identity/Pages/V5/Account/ExternalLogin.cshtml
This file contains hidden or 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"></div> | ||
<div class="form-group"> | ||
<label asp-for="Input.Email"></label> | ||
<input asp-for="Input.Email" class="form-control" autocomplete="email" /> | ||
<span asp-validation-for="Input.Email" class="text-danger"></span> | ||
</div> | ||
<button type="submit" class="btn btn-primary">Register</button> | ||
</form> | ||
</div> | ||
</div> | ||
|
||
@section Scripts { | ||
<partial name="_ValidationScriptsPartial" /> | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we might want to change these to be V5 namespaces right @javiercn or will this change so it doesn't matter?