-
-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: login page register and pwd links
* feat: login page register and pwd links #790 #792 * revert sample change * remove code smell * improve localization Co-authored-by: github-actions <[email protected]>
- Loading branch information
1 parent
a7110d1
commit 1ee72d6
Showing
17 changed files
with
460 additions
and
5 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
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
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
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
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
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
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
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
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
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
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
27 changes: 27 additions & 0 deletions
27
src/Aguacongas.TheIdServer/Areas/Identity/Pages/Account/ResendEmailConfirmation.cshtml
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,27 @@ | ||
@page | ||
@inject IViewLocalizer Localizer | ||
@model ResendEmailConfirmationModel | ||
@{ | ||
ViewData["Title"] = Localizer["Resend email confirmation"]; | ||
} | ||
|
||
<h1>@ViewData["Title"]</h1> | ||
<h2>@Localizer["Enter your email."]</h2> | ||
<hr /> | ||
<div class="row"> | ||
<div class="col-md-4"> | ||
<form method="post"> | ||
<div asp-validation-summary="All" class="text-danger"></div> | ||
<div class="form-floating mb-2"> | ||
<input asp-for="Input.Email" class="form-control" aria-required="true" /> | ||
<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">@Localizer["Resend"]</button> | ||
</form> | ||
</div> | ||
</div> | ||
|
||
@section Scripts { | ||
<partial name="_ValidationScriptsPartial" /> | ||
} |
87 changes: 87 additions & 0 deletions
87
src/Aguacongas.TheIdServer/Areas/Identity/Pages/Account/ResendEmailConfirmation.cshtml.cs
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,87 @@ | ||
// 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 Aguacongas.TheIdServer.Models; | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Identity; | ||
using Microsoft.AspNetCore.Identity.UI.Services; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.RazorPages; | ||
using Microsoft.AspNetCore.WebUtilities; | ||
using Microsoft.Extensions.Localization; | ||
using System.ComponentModel.DataAnnotations; | ||
using System.Text; | ||
using System.Text.Encodings.Web; | ||
using System.Threading.Tasks; | ||
|
||
namespace Aguacongas.TheIdServer.Areas.Identity.Pages.Account | ||
{ | ||
[AllowAnonymous] | ||
public class ResendEmailConfirmationModel : PageModel | ||
{ | ||
private readonly UserManager<ApplicationUser> _userManager; | ||
private readonly IEmailSender _emailSender; | ||
private readonly IStringLocalizer _localizer; | ||
|
||
public ResendEmailConfirmationModel(UserManager<ApplicationUser> userManager, IEmailSender emailSender, IStringLocalizer<ResendEmailConfirmationModel> localizer) | ||
{ | ||
_userManager = userManager; | ||
_emailSender = emailSender; | ||
_localizer = localizer; | ||
} | ||
|
||
/// <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> | ||
[BindProperty] | ||
public InputModel Input { 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 class InputModel | ||
{ | ||
/// <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> | ||
[Required] | ||
[EmailAddress] | ||
public string Email { get; set; } | ||
} | ||
|
||
public async Task<IActionResult> OnPostAsync() | ||
{ | ||
if (!ModelState.IsValid) | ||
{ | ||
return Page(); | ||
} | ||
|
||
var user = await _userManager.FindByEmailAsync(Input.Email); | ||
if (user == null) | ||
{ | ||
ModelState.AddModelError(string.Empty, _localizer["Verification email sent. Please check your email."]); | ||
return Page(); | ||
} | ||
|
||
var userId = await _userManager.GetUserIdAsync(user); | ||
var code = await _userManager.GenerateEmailConfirmationTokenAsync(user); | ||
code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code)); | ||
var callbackUrl = Url.Page( | ||
"/Account/ConfirmEmail", | ||
pageHandler: null, | ||
values: new { area = "Identity", userId = userId, code = code }, | ||
protocol: Request.Scheme); | ||
await _emailSender.SendEmailAsync( | ||
Input.Email, | ||
_localizer["Confirm your email"], | ||
_localizer[$"Please confirm your account by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a>."]); | ||
|
||
ModelState.AddModelError(string.Empty, _localizer["Verification email sent. Please check your email."]); | ||
return Page(); | ||
} | ||
} | ||
} |
Oops, something went wrong.