Skip to content

Commit 709038b

Browse files
authored
Update to bootstrap5 (#34052)
1 parent d97184a commit 709038b

File tree

291 files changed

+209310
-70921
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

291 files changed

+209310
-70921
lines changed

src/Identity/UI/src/Areas/Identity/Filters/ExternalLoginsPageFilter.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
// Licensed to the .NET Foundation under one or more agreements.
1+
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
using System.Linq;
5-
using System.Threading.Tasks;
64
using Microsoft.AspNetCore.Mvc.Filters;
75
using Microsoft.AspNetCore.Mvc.RazorPages;
86
using Microsoft.Extensions.DependencyInjection;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
@page
2+
@model AccessDeniedModel
3+
@{
4+
ViewData["Title"] = "Access denied";
5+
}
6+
7+
<header>
8+
<h1 class="text-danger">@ViewData["Title"]</h1>
9+
<p class="text-danger">You do not have access to this resource.</p>
10+
</header>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using Microsoft.AspNetCore.Mvc.RazorPages;
5+
6+
namespace Microsoft.AspNetCore.Identity.UI.V5.Pages.Account.Internal
7+
{
8+
/// <summary>
9+
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used
10+
/// directly from your code. This API may change or be removed in future releases.
11+
/// </summary>
12+
public class AccessDeniedModel : PageModel
13+
{
14+
/// <summary>
15+
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used
16+
/// directly from your code. This API may change or be removed in future releases.
17+
/// </summary>
18+
public void OnGet()
19+
{
20+
}
21+
}
22+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@page
2+
@model ConfirmEmailModel
3+
@{
4+
ViewData["Title"] = "Confirm email";
5+
}
6+
7+
<h1>@ViewData["Title"]</h1>
8+
<partial name="_StatusMessage" model="Model.StatusMessage" />
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using Microsoft.AspNetCore.Authorization;
8+
using Microsoft.AspNetCore.Mvc;
9+
using Microsoft.AspNetCore.Mvc.RazorPages;
10+
using Microsoft.AspNetCore.WebUtilities;
11+
12+
namespace Microsoft.AspNetCore.Identity.UI.V5.Pages.Account.Internal
13+
{
14+
/// <summary>
15+
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used
16+
/// directly from your code. This API may change or be removed in future releases.
17+
/// </summary>
18+
[AllowAnonymous]
19+
[IdentityDefaultUI(typeof(ConfirmEmailModel<>))]
20+
public abstract class ConfirmEmailModel : PageModel
21+
{
22+
/// <summary>
23+
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used
24+
/// directly from your code. This API may change or be removed in future releases.
25+
/// </summary>
26+
[TempData]
27+
public string StatusMessage { get; set; }
28+
29+
/// <summary>
30+
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used
31+
/// directly from your code. This API may change or be removed in future releases.
32+
/// </summary>
33+
public virtual Task<IActionResult> OnGetAsync(string userId, string code) => throw new NotImplementedException();
34+
}
35+
36+
internal class ConfirmEmailModel<TUser> : ConfirmEmailModel where TUser : class
37+
{
38+
private readonly UserManager<TUser> _userManager;
39+
40+
public ConfirmEmailModel(UserManager<TUser> userManager)
41+
{
42+
_userManager = userManager;
43+
}
44+
45+
public override async Task<IActionResult> OnGetAsync(string userId, string code)
46+
{
47+
if (userId == null || code == null)
48+
{
49+
return RedirectToPage("/Index");
50+
}
51+
52+
var user = await _userManager.FindByIdAsync(userId);
53+
if (user == null)
54+
{
55+
return NotFound($"Unable to load user with ID '{userId}'.");
56+
}
57+
58+
code = Encoding.UTF8.GetString(WebEncoders.Base64UrlDecode(code));
59+
var result = await _userManager.ConfirmEmailAsync(user, code);
60+
StatusMessage = result.Succeeded ? "Thank you for confirming your email." : "Error confirming your email.";
61+
return Page();
62+
}
63+
}
64+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@page
2+
@model ConfirmEmailChangeModel
3+
@{
4+
ViewData["Title"] = "Confirm email change";
5+
}
6+
7+
<h1>@ViewData["Title"]</h1>
8+
<partial name="_StatusMessage" model="Model.StatusMessage" />
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using Microsoft.AspNetCore.Authorization;
8+
using Microsoft.AspNetCore.Mvc;
9+
using Microsoft.AspNetCore.Mvc.RazorPages;
10+
using Microsoft.AspNetCore.WebUtilities;
11+
12+
namespace Microsoft.AspNetCore.Identity.UI.V5.Pages.Account.Internal
13+
{
14+
/// <summary>
15+
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used
16+
/// directly from your code. This API may change or be removed in future releases.
17+
/// </summary>
18+
[AllowAnonymous]
19+
[IdentityDefaultUI(typeof(ConfirmEmailChangeModel<>))]
20+
public abstract class ConfirmEmailChangeModel : PageModel
21+
{
22+
/// <summary>
23+
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used
24+
/// directly from your code. This API may change or be removed in future releases.
25+
/// </summary>
26+
[TempData]
27+
public string StatusMessage { get; set; }
28+
29+
/// <summary>
30+
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used
31+
/// directly from your code. This API may change or be removed in future releases.
32+
/// </summary>
33+
public virtual Task<IActionResult> OnGetAsync(string userId, string email, string code) => throw new NotImplementedException();
34+
}
35+
36+
internal class ConfirmEmailChangeModel<TUser> : ConfirmEmailChangeModel where TUser : class
37+
{
38+
private readonly UserManager<TUser> _userManager;
39+
private readonly SignInManager<TUser> _signInManager;
40+
41+
public ConfirmEmailChangeModel(UserManager<TUser> userManager, SignInManager<TUser> signInManager)
42+
{
43+
_userManager = userManager;
44+
_signInManager = signInManager;
45+
}
46+
47+
public override async Task<IActionResult> OnGetAsync(string userId, string email, string code)
48+
{
49+
if (userId == null || email == null || code == null)
50+
{
51+
return RedirectToPage("/Index");
52+
}
53+
54+
var user = await _userManager.FindByIdAsync(userId);
55+
if (user == null)
56+
{
57+
return NotFound($"Unable to load user with ID '{userId}'.");
58+
}
59+
60+
code = Encoding.UTF8.GetString(WebEncoders.Base64UrlDecode(code));
61+
var result = await _userManager.ChangeEmailAsync(user, email, code);
62+
if (!result.Succeeded)
63+
{
64+
StatusMessage = "Error changing email.";
65+
return Page();
66+
}
67+
68+
// In our UI email and user name are one and the same, so when we update the email
69+
// we need to update the user name.
70+
var setUserNameResult = await _userManager.SetUserNameAsync(user, email);
71+
if (!setUserNameResult.Succeeded)
72+
{
73+
StatusMessage = "Error changing user name.";
74+
return Page();
75+
}
76+
77+
await _signInManager.RefreshSignInAsync(user);
78+
StatusMessage = "Thank you for confirming your email change.";
79+
return Page();
80+
}
81+
}
82+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
@page
2+
@model ExternalLoginModel
3+
@{
4+
ViewData["Title"] = "Register";
5+
}
6+
7+
<h1>@ViewData["Title"]</h1>
8+
<h2 id="external-login-title">Associate your @Model.ProviderDisplayName account.</h2>
9+
<hr />
10+
11+
<p id="external-login-description" class="text-info">
12+
You've successfully authenticated with <strong>@Model.ProviderDisplayName</strong>.
13+
Please enter an email address for this site below and click the Register button to finish
14+
logging in.
15+
</p>
16+
17+
<div class="row">
18+
<div class="col-md-4">
19+
<form asp-page-handler="Confirmation" asp-route-returnUrl="@Model.ReturnUrl" method="post">
20+
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
21+
<div class="form-group">
22+
<label asp-for="Input.Email"></label>
23+
<input asp-for="Input.Email" class="form-control" autocomplete="email" />
24+
<span asp-validation-for="Input.Email" class="text-danger"></span>
25+
</div>
26+
<button type="submit" class="btn btn-primary">Register</button>
27+
</form>
28+
</div>
29+
</div>
30+
31+
@section Scripts {
32+
<partial name="_ValidationScriptsPartial" />
33+
}

0 commit comments

Comments
 (0)