-
-
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
- Loading branch information
github-actions
committed
May 28, 2022
1 parent
407acbe
commit 2914654
Showing
14 changed files
with
406 additions
and
4 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
26 changes: 26 additions & 0 deletions
26
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,26 @@ | ||
@page | ||
@model ResendEmailConfirmationModel | ||
@{ | ||
ViewData["Title"] = "Resend email confirmation"; | ||
} | ||
|
||
<h1>@ViewData["Title"]</h1> | ||
<h2>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">Resend</button> | ||
</form> | ||
</div> | ||
</div> | ||
|
||
@section Scripts { | ||
<partial name="_ValidationScriptsPartial" /> | ||
} |
91 changes: 91 additions & 0 deletions
91
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,91 @@ | ||
// 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 void OnGet() | ||
{ | ||
} | ||
|
||
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(); | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
src/Aguacongas.TheIdServer/Areas/Identity/Pages/Account/ResetPassword.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,44 @@ | ||
@* | ||
Project: Aguafrommars/TheIdServer | ||
Copyright (c) 2022 @Olivier Lefebvre | ||
*@ | ||
@page | ||
@inject IViewLocalizer Localizer | ||
|
||
@model ResetPasswordModel | ||
@{ | ||
ViewData["Title"] = Localizer["Reset password"]; | ||
} | ||
|
||
<h1>@ViewData["Title"]</h1> | ||
<h2>@Localizer["Reset your password."]</h2> | ||
<hr /> | ||
<div class="row"> | ||
<div class="col-md-4"> | ||
<form method="post"> | ||
<div asp-validation-summary="ModelOnly" class="text-danger"></div> | ||
<input asp-for="Input.Code" type="hidden" /> | ||
<input asp-for="Input.ReturnUrl" type="hidden" /> | ||
<div class="form-floating mb-2"> | ||
<input asp-for="Input.Email" class="form-control" autocomplete="username" aria-required="true" /> | ||
<label asp-for="Input.Email" class="form-label"></label> | ||
<span asp-validation-for="Input.Email" class="text-danger"></span> | ||
</div> | ||
<div class="form-floating mb-2"> | ||
<input asp-for="Input.Password" class="form-control" autocomplete="new-password" aria-required="true" /> | ||
<label asp-for="Input.Password" class="form-label"></label> | ||
<span asp-validation-for="Input.Password" class="text-danger"></span> | ||
</div> | ||
<div class="form-floating mb-2"> | ||
<input asp-for="Input.ConfirmPassword" class="form-control" autocomplete="new-password" aria-required="true" /> | ||
<label asp-for="Input.ConfirmPassword" class="form-label"></label> | ||
<span asp-validation-for="Input.ConfirmPassword" class="text-danger"></span> | ||
</div> | ||
<button type="submit" class="w-100 btn btn-lg btn-primary">@Localizer["Reset"]</button> | ||
</form> | ||
</div> | ||
</div> | ||
|
||
@section Scripts { | ||
<partial name="_ValidationScriptsPartial" /> | ||
} |
Oops, something went wrong.