-
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/AccessDenied.cshtml.cs b/Kemkas.Web/Areas/Identity/Pages/Account/AccessDenied.cshtml.cs
deleted file mode 100644
index 65f0d7a..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/AccessDenied.cshtml.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-// 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 Kemkas.Web.Areas.Identity.Pages.Account
-{
- ///
- /// 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.
- ///
- public class AccessDeniedModel : PageModel
- {
- ///
- /// 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.
- ///
- public void OnGet()
- {
- }
- }
-}
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/ConfirmEmail.cshtml b/Kemkas.Web/Areas/Identity/Pages/Account/ConfirmEmail.cshtml
deleted file mode 100644
index 2deb2e5..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/ConfirmEmail.cshtml
+++ /dev/null
@@ -1,8 +0,0 @@
-@page
-@model ConfirmEmailModel
-@{
- ViewData["Title"] = "Confirm email";
-}
-
-
@ViewData["Title"]
-
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/ConfirmEmail.cshtml.cs b/Kemkas.Web/Areas/Identity/Pages/Account/ConfirmEmail.cshtml.cs
deleted file mode 100644
index 88f8297..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/ConfirmEmail.cshtml.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-// 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 Kemkas.Web.Db.Models;
-using Microsoft.AspNetCore.Identity;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.AspNetCore.Mvc.RazorPages;
-using Microsoft.AspNetCore.WebUtilities;
-
-namespace Kemkas.Web.Areas.Identity.Pages.Account
-{
- public class ConfirmEmailModel : PageModel
- {
- private readonly UserManager _userManager;
-
- public ConfirmEmailModel(UserManager userManager)
- {
- _userManager = userManager;
- }
-
- ///
- /// 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.
- ///
- [TempData]
- public string StatusMessage { get; set; }
- public async Task 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();
- }
- }
-}
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/ConfirmEmailChange.cshtml b/Kemkas.Web/Areas/Identity/Pages/Account/ConfirmEmailChange.cshtml
deleted file mode 100644
index 114fa88..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/ConfirmEmailChange.cshtml
+++ /dev/null
@@ -1,8 +0,0 @@
-@page
-@model ConfirmEmailChangeModel
-@{
- ViewData["Title"] = "Confirm email change";
-}
-
-
@ViewData["Title"]
-
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/ConfirmEmailChange.cshtml.cs b/Kemkas.Web/Areas/Identity/Pages/Account/ConfirmEmailChange.cshtml.cs
deleted file mode 100644
index 676afd1..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/ConfirmEmailChange.cshtml.cs
+++ /dev/null
@@ -1,70 +0,0 @@
-// 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 Kemkas.Web.Db.Models;
-using Microsoft.AspNetCore.Identity;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.AspNetCore.Mvc.RazorPages;
-using Microsoft.AspNetCore.WebUtilities;
-
-namespace Kemkas.Web.Areas.Identity.Pages.Account
-{
- public class ConfirmEmailChangeModel : PageModel
- {
- private readonly UserManager _userManager;
- private readonly SignInManager _signInManager;
-
- public ConfirmEmailChangeModel(UserManager userManager, SignInManager signInManager)
- {
- _userManager = userManager;
- _signInManager = signInManager;
- }
-
- ///
- /// 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.
- ///
- [TempData]
- public string StatusMessage { get; set; }
-
- public async Task 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();
- }
- }
-}
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/ExternalLogin.cshtml b/Kemkas.Web/Areas/Identity/Pages/Account/ExternalLogin.cshtml
deleted file mode 100644
index 5c99bad..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/ExternalLogin.cshtml
+++ /dev/null
@@ -1,33 +0,0 @@
-@page
-@model ExternalLoginModel
-@{
- ViewData["Title"] = "Register";
-}
-
-
@ViewData["Title"]
-
Associate your @Model.ProviderDisplayName account.
-
-
-
- You've successfully authenticated with @Model.ProviderDisplayName.
- Please enter an email address for this site below and click the Register button to finish
- logging in.
-
-
-
-
-
-
-
-
-@section Scripts {
-
-}
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/ExternalLogin.cshtml.cs b/Kemkas.Web/Areas/Identity/Pages/Account/ExternalLogin.cshtml.cs
deleted file mode 100644
index e312d95..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/ExternalLogin.cshtml.cs
+++ /dev/null
@@ -1,246 +0,0 @@
-// 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.ComponentModel.DataAnnotations;
-using System.Security.Claims;
-using System.Text;
-using System.Text.Encodings.Web;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.AspNetCore.Authorization;
-using Microsoft.Extensions.Options;
-using Kemkas.Web.Db.Models;
-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.Logging;
-
-namespace Kemkas.Web.Areas.Identity.Pages.Account
-{
- [AllowAnonymous]
- public class ExternalLoginModel : PageModel
- {
- private readonly SignInManager _signInManager;
- private readonly UserManager _userManager;
- private readonly IUserStore _userStore;
- private readonly IUserEmailStore _emailStore;
- private readonly IEmailSender _emailSender;
- private readonly ILogger _logger;
-
- public ExternalLoginModel(
- SignInManager signInManager,
- UserManager userManager,
- IUserStore userStore,
- ILogger logger,
- IEmailSender emailSender)
- {
- _signInManager = signInManager;
- _userManager = userManager;
- _userStore = userStore;
- _emailStore = GetEmailStore();
- _logger = logger;
- _emailSender = emailSender;
- }
-
- ///
- /// 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.
- ///
- [BindProperty]
- public InputModel Input { get; set; }
-
- ///
- /// 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.
- ///
- public string ProviderDisplayName { get; set; }
-
- ///
- /// 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.
- ///
- public string ReturnUrl { get; set; }
-
- ///
- /// 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.
- ///
- [TempData]
- public string ErrorMessage { get; set; }
-
- ///
- /// 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.
- ///
- public class InputModel
- {
- ///
- /// 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.
- ///
- [Required]
- [EmailAddress]
- public string Email { get; set; }
- }
-
- public IActionResult OnGet() => RedirectToPage("./Login");
-
- public IActionResult OnPost(string provider, string returnUrl = null)
- {
- // Request a redirect to the external login provider.
- var redirectUrl = Url.Page("./ExternalLogin", pageHandler: "Callback", values: new { returnUrl });
- var properties = _signInManager.ConfigureExternalAuthenticationProperties(provider, redirectUrl);
- return new ChallengeResult(provider, properties);
- }
-
- public async Task OnGetCallbackAsync(string returnUrl = null, string remoteError = null)
- {
- returnUrl = returnUrl ?? Url.Content("~/");
- if (remoteError != null)
- {
- ErrorMessage = $"Error from external provider: {remoteError}";
- return RedirectToPage("./Login", new { ReturnUrl = returnUrl });
- }
- var info = await _signInManager.GetExternalLoginInfoAsync();
- if (info == null)
- {
- ErrorMessage = "Error loading external login information.";
- return RedirectToPage("./Login", new { ReturnUrl = returnUrl });
- }
-
- // Sign in the user with this external login provider if the user already has a login.
- var result = await _signInManager.ExternalLoginSignInAsync(info.LoginProvider, info.ProviderKey, isPersistent: false, bypassTwoFactor: true);
- if (result.Succeeded)
- {
- _logger.LogInformation("{Name} logged in with {LoginProvider} provider.", info.Principal.Identity.Name, info.LoginProvider);
- return LocalRedirect(returnUrl);
- }
- if (result.IsLockedOut)
- {
- return RedirectToPage("./Lockout");
- }
-
- // If the user does not have an account, and no email claim, then ask the user to create an account.
- ReturnUrl = returnUrl;
- ProviderDisplayName = info.ProviderDisplayName;
- if (!info.Principal.HasClaim(c => c.Type == ClaimTypes.Email))
- {
- return Page();
- }
-
- // User doesn't have account but external provider has email claim. => Register with claimed email.
- Input = new InputModel
- {
- Email = info.Principal.FindFirstValue(ClaimTypes.Email)
- };
- var user = CreateUser();
- await _userStore.SetUserNameAsync(user, Input.Email, CancellationToken.None);
- await _emailStore.SetEmailAsync(user, Input.Email, CancellationToken.None);
- var registrationResult = await _userManager.CreateAsync(user);
- if (registrationResult.Succeeded)
- {
- registrationResult = await _userManager.AddLoginAsync(user, info);
- if (registrationResult.Succeeded)
- {
- _logger.LogInformation("User created an account using {Name} provider.", info.LoginProvider);
- var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);
- await _userManager.ConfirmEmailAsync(user, code);
- await _signInManager.SignInAsync(user, isPersistent: false, info.LoginProvider);
- return LocalRedirect(returnUrl);
- }
- }
- foreach (var error in registrationResult.Errors)
- {
- ModelState.AddModelError(string.Empty, error.Description);
- }
-
- return Page();
- }
-
- public async Task OnPostConfirmationAsync(string returnUrl = null)
- {
- returnUrl = returnUrl ?? Url.Content("~/");
- // Get the information about the user from the external login provider
- var info = await _signInManager.GetExternalLoginInfoAsync();
- if (info == null)
- {
- ErrorMessage = "Error loading external login information during confirmation.";
- return RedirectToPage("./Login", new { ReturnUrl = returnUrl });
- }
-
- if (ModelState.IsValid)
- {
- var user = CreateUser();
-
- await _userStore.SetUserNameAsync(user, Input.Email, CancellationToken.None);
- await _emailStore.SetEmailAsync(user, Input.Email, CancellationToken.None);
-
- var result = await _userManager.CreateAsync(user);
- if (result.Succeeded)
- {
- result = await _userManager.AddLoginAsync(user, info);
- if (result.Succeeded)
- {
- _logger.LogInformation("User created an account using {Name} provider.", info.LoginProvider);
-
- 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, "Confirm your email",
- $"Please confirm your account by clicking here.");
-
- // If account confirmation is required, we need to show the link if we don't have a real email sender
- if (_userManager.Options.SignIn.RequireConfirmedAccount)
- {
- return RedirectToPage("./RegisterConfirmation", new { Email = Input.Email });
- }
-
- await _signInManager.SignInAsync(user, isPersistent: false, info.LoginProvider);
- return LocalRedirect(returnUrl);
- }
- }
- foreach (var error in result.Errors)
- {
- ModelState.AddModelError(string.Empty, error.Description);
- }
- }
-
- ProviderDisplayName = info.ProviderDisplayName;
- ReturnUrl = returnUrl;
- return Page();
- }
-
- private ApplicationUser CreateUser()
- {
- try
- {
- return Activator.CreateInstance();
- }
- catch
- {
- throw new InvalidOperationException($"Can't create an instance of '{nameof(ApplicationUser)}'. " +
- $"Ensure that '{nameof(ApplicationUser)}' is not an abstract class and has a parameterless constructor, or alternatively " +
- $"override the external login page in /Areas/Identity/Pages/Account/ExternalLogin.cshtml");
- }
- }
-
- private IUserEmailStore GetEmailStore()
- {
- if (!_userManager.SupportsUserEmail)
- {
- throw new NotSupportedException("The default UI requires a user store with email support.");
- }
- return (IUserEmailStore)_userStore;
- }
- }
-}
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/ForgotPassword.cshtml b/Kemkas.Web/Areas/Identity/Pages/Account/ForgotPassword.cshtml
deleted file mode 100644
index 106b8d1..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/ForgotPassword.cshtml
+++ /dev/null
@@ -1,26 +0,0 @@
-@page
-@model ForgotPasswordModel
-@{
- ViewData["Title"] = "Forgot your password?";
-}
-
-
@ViewData["Title"]
-
Enter your email.
-
-
-
-
-
-
-
-@section Scripts {
-
-}
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/ForgotPassword.cshtml.cs b/Kemkas.Web/Areas/Identity/Pages/Account/ForgotPassword.cshtml.cs
deleted file mode 100644
index 44550e8..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/ForgotPassword.cshtml.cs
+++ /dev/null
@@ -1,85 +0,0 @@
-// 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.ComponentModel.DataAnnotations;
-using System.Text;
-using System.Text.Encodings.Web;
-using System.Threading.Tasks;
-using Microsoft.AspNetCore.Authorization;
-using Kemkas.Web.Db.Models;
-using Microsoft.AspNetCore.Identity;
-using Microsoft.AspNetCore.Identity.UI.Services;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.AspNetCore.Mvc.RazorPages;
-using Microsoft.AspNetCore.WebUtilities;
-
-namespace Kemkas.Web.Areas.Identity.Pages.Account
-{
- public class ForgotPasswordModel : PageModel
- {
- private readonly UserManager _userManager;
- private readonly IEmailSender _emailSender;
-
- public ForgotPasswordModel(UserManager userManager, IEmailSender emailSender)
- {
- _userManager = userManager;
- _emailSender = emailSender;
- }
-
- ///
- /// 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.
- ///
- [BindProperty]
- public InputModel Input { get; set; }
-
- ///
- /// 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.
- ///
- public class InputModel
- {
- ///
- /// 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.
- ///
- [Required]
- [EmailAddress]
- public string Email { get; set; }
- }
-
- public async Task OnPostAsync()
- {
- if (ModelState.IsValid)
- {
- var user = await _userManager.FindByEmailAsync(Input.Email);
- if (user == null || !(await _userManager.IsEmailConfirmedAsync(user)))
- {
- // Don't reveal that the user does not exist or is not confirmed
- return RedirectToPage("./ForgotPasswordConfirmation");
- }
-
- // For more information on how to enable account confirmation and password reset please
- // visit https://go.microsoft.com/fwlink/?LinkID=532713
- var code = await _userManager.GeneratePasswordResetTokenAsync(user);
- code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code));
- var callbackUrl = Url.Page(
- "/Account/ResetPassword",
- pageHandler: null,
- values: new { area = "Identity", code },
- protocol: Request.Scheme);
-
- await _emailSender.SendEmailAsync(
- Input.Email,
- "Reset Password",
- $"Please reset your password by clicking here.");
-
- return RedirectToPage("./ForgotPasswordConfirmation");
- }
-
- return Page();
- }
- }
-}
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/ForgotPasswordConfirmation.cshtml b/Kemkas.Web/Areas/Identity/Pages/Account/ForgotPasswordConfirmation.cshtml
deleted file mode 100644
index 4f5ae99..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/ForgotPasswordConfirmation.cshtml
+++ /dev/null
@@ -1,10 +0,0 @@
-@page
-@model ForgotPasswordConfirmation
-@{
- ViewData["Title"] = "Forgot password confirmation";
-}
-
-
@ViewData["Title"]
-
- Please check your email to reset your password.
-
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/ForgotPasswordConfirmation.cshtml.cs b/Kemkas.Web/Areas/Identity/Pages/Account/ForgotPasswordConfirmation.cshtml.cs
deleted file mode 100644
index d1f72ff..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/ForgotPasswordConfirmation.cshtml.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-// 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.Authorization;
-using Microsoft.AspNetCore.Mvc.RazorPages;
-
-namespace Kemkas.Web.Areas.Identity.Pages.Account
-{
- ///
- /// 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.
- ///
- [AllowAnonymous]
- public class ForgotPasswordConfirmation : PageModel
- {
- ///
- /// 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.
- ///
- public void OnGet()
- {
- }
- }
-}
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/Lockout.cshtml b/Kemkas.Web/Areas/Identity/Pages/Account/Lockout.cshtml
deleted file mode 100644
index 4eded88..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/Lockout.cshtml
+++ /dev/null
@@ -1,10 +0,0 @@
-@page
-@model LockoutModel
-@{
- ViewData["Title"] = "Locked out";
-}
-
-
-
@ViewData["Title"]
-
This account has been locked out, please try again later.
-
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/Lockout.cshtml.cs b/Kemkas.Web/Areas/Identity/Pages/Account/Lockout.cshtml.cs
deleted file mode 100644
index a0187fc..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/Lockout.cshtml.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-// 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.Authorization;
-using Microsoft.AspNetCore.Mvc.RazorPages;
-
-namespace Kemkas.Web.Areas.Identity.Pages.Account
-{
- ///
- /// 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.
- ///
- [AllowAnonymous]
- public class LockoutModel : PageModel
- {
- ///
- /// 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.
- ///
- public void OnGet()
- {
- }
- }
-}
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/Login.cshtml b/Kemkas.Web/Areas/Identity/Pages/Account/Login.cshtml
deleted file mode 100644
index 4631e8a..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/Login.cshtml
+++ /dev/null
@@ -1,84 +0,0 @@
-@page
-@model LoginModel
-
-@{
- ViewData["Title"] = "Log in";
-}
-
-
-
-@section Scripts {
-
-}
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/Login.cshtml.cs b/Kemkas.Web/Areas/Identity/Pages/Account/Login.cshtml.cs
deleted file mode 100644
index 936edc0..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/Login.cshtml.cs
+++ /dev/null
@@ -1,155 +0,0 @@
-// 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.Collections.Generic;
-using System.ComponentModel.DataAnnotations;
-using System.Linq;
-using System.Threading.Tasks;
-using Microsoft.AspNetCore.Authorization;
-using Kemkas.Web.Db.Models;
-using Microsoft.AspNetCore.Authentication;
-using Microsoft.AspNetCore.Identity;
-using Microsoft.AspNetCore.Identity.UI.Services;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.AspNetCore.Mvc.RazorPages;
-using Microsoft.Extensions.Logging;
-
-namespace Kemkas.Web.Areas.Identity.Pages.Account
-{
- public class LoginModel : PageModel
- {
- private readonly SignInManager _signInManager;
- private readonly ILogger _logger;
- private readonly IWebHostEnvironment _environment;
-
- public LoginModel(SignInManager signInManager, ILogger logger, IWebHostEnvironment environment)
- {
- _signInManager = signInManager;
- _logger = logger;
- _environment = environment;
- }
-
- ///
- /// 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.
- ///
- [BindProperty]
- public InputModel Input { get; set; }
-
- ///
- /// 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.
- ///
- public IList ExternalLogins { get; set; }
-
- ///
- /// 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.
- ///
- public string ReturnUrl { get; set; }
-
- ///
- /// 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.
- ///
- [TempData]
- public string ErrorMessage { get; set; }
-
- ///
- /// 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.
- ///
- public class InputModel
- {
- ///
- /// 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.
- ///
- [Required]
- [EmailAddress]
- public string Email { get; set; }
-
- ///
- /// 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.
- ///
- [Required]
- [DataType(DataType.Password)]
- public string Password { get; set; }
-
- ///
- /// 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.
- ///
- [Display(Name = "Remember me?")]
- public bool RememberMe { get; set; }
- }
-
- public async Task OnGetAsync(string returnUrl = null)
- {
- if (!string.IsNullOrEmpty(ErrorMessage))
- {
- ModelState.AddModelError(string.Empty, ErrorMessage);
- }
-
- returnUrl ??= Url.Content("~/");
-
- // Clear the existing external cookie to ensure a clean login process
- await HttpContext.SignOutAsync(IdentityConstants.ExternalScheme);
-
- ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList();
-
- // Disable not yet approved external login providers in production
- if (!_environment.IsDevelopment())
- {
- ExternalLogins = ExternalLogins.Where(el => el.Name == "Discord").ToList();
- }
-
- ReturnUrl = returnUrl;
- }
-
- public async Task OnPostAsync(string returnUrl = null)
- {
- returnUrl ??= Url.Content("~/");
-
- ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList();
-
- // Disable not yet approved external login providers in production
- if (!_environment.IsDevelopment())
- {
- ExternalLogins = ExternalLogins.Where(el => el.Name == "Discord").ToList();
- }
-
- if (ModelState.IsValid)
- {
- // This doesn't count login failures towards account lockout
- // To enable password failures to trigger account lockout, set lockoutOnFailure: true
- var result = await _signInManager.PasswordSignInAsync(Input.Email, Input.Password, Input.RememberMe, lockoutOnFailure: false);
- if (result.Succeeded)
- {
- _logger.LogInformation("User logged in.");
- return LocalRedirect(returnUrl);
- }
- if (result.RequiresTwoFactor)
- {
- return RedirectToPage("./LoginWith2fa", new { ReturnUrl = returnUrl, RememberMe = Input.RememberMe });
- }
- if (result.IsLockedOut)
- {
- _logger.LogWarning("User account locked out.");
- return RedirectToPage("./Lockout");
- }
- else
- {
- ModelState.AddModelError(string.Empty, "Invalid login attempt.");
- return Page();
- }
- }
-
- // If we got this far, something failed, redisplay form
- return Page();
- }
- }
-}
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/LoginWith2fa.cshtml b/Kemkas.Web/Areas/Identity/Pages/Account/LoginWith2fa.cshtml
deleted file mode 100644
index 87d9831..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/LoginWith2fa.cshtml
+++ /dev/null
@@ -1,39 +0,0 @@
-@page
-@model LoginWith2faModel
-@{
- ViewData["Title"] = "Two-factor authentication";
-}
-
-
@ViewData["Title"]
-
-
Your login is protected with an authenticator app. Enter your authenticator code below.
-
-@section Scripts {
-
-}
\ No newline at end of file
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/LoginWith2fa.cshtml.cs b/Kemkas.Web/Areas/Identity/Pages/Account/LoginWith2fa.cshtml.cs
deleted file mode 100644
index 79b7252..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/LoginWith2fa.cshtml.cs
+++ /dev/null
@@ -1,132 +0,0 @@
-// 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.ComponentModel.DataAnnotations;
-using System.Threading.Tasks;
-using Microsoft.AspNetCore.Authorization;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.AspNetCore.Mvc.RazorPages;
-using Microsoft.Extensions.Logging;
-using Kemkas.Web.Db.Models;
-using Microsoft.AspNetCore.Identity;
-using Microsoft.Extensions.Logging;
-
-namespace Kemkas.Web.Areas.Identity.Pages.Account
-{
- public class LoginWith2faModel : PageModel
- {
- private readonly SignInManager _signInManager;
- private readonly UserManager _userManager;
- private readonly ILogger _logger;
-
- public LoginWith2faModel(
- SignInManager signInManager,
- UserManager userManager,
- ILogger logger)
- {
- _signInManager = signInManager;
- _userManager = userManager;
- _logger = logger;
- }
-
- ///
- /// 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.
- ///
- [BindProperty]
- public InputModel Input { get; set; }
-
- ///
- /// 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.
- ///
- public bool RememberMe { get; set; }
-
- ///
- /// 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.
- ///
- public string ReturnUrl { get; set; }
-
- ///
- /// 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.
- ///
- public class InputModel
- {
- ///
- /// 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.
- ///
- [Required]
- [StringLength(7, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", MinimumLength = 6)]
- [DataType(DataType.Text)]
- [Display(Name = "Authenticator code")]
- public string TwoFactorCode { get; set; }
-
- ///
- /// 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.
- ///
- [Display(Name = "Remember this machine")]
- public bool RememberMachine { get; set; }
- }
-
- public async Task OnGetAsync(bool rememberMe, string returnUrl = null)
- {
- // Ensure the user has gone through the username & password screen first
- var user = await _signInManager.GetTwoFactorAuthenticationUserAsync();
-
- if (user == null)
- {
- throw new InvalidOperationException($"Unable to load two-factor authentication user.");
- }
-
- ReturnUrl = returnUrl;
- RememberMe = rememberMe;
-
- return Page();
- }
-
- public async Task OnPostAsync(bool rememberMe, string returnUrl = null)
- {
- if (!ModelState.IsValid)
- {
- return Page();
- }
-
- returnUrl = returnUrl ?? Url.Content("~/");
-
- var user = await _signInManager.GetTwoFactorAuthenticationUserAsync();
- if (user == null)
- {
- throw new InvalidOperationException($"Unable to load two-factor authentication user.");
- }
-
- var authenticatorCode = Input.TwoFactorCode.Replace(" ", string.Empty).Replace("-", string.Empty);
-
- var result = await _signInManager.TwoFactorAuthenticatorSignInAsync(authenticatorCode, rememberMe, Input.RememberMachine);
-
- var userId = await _userManager.GetUserIdAsync(user);
-
- if (result.Succeeded)
- {
- _logger.LogInformation("User with ID '{UserId}' logged in with 2fa.", user.Id);
- return LocalRedirect(returnUrl);
- }
- else if (result.IsLockedOut)
- {
- _logger.LogWarning("User with ID '{UserId}' account locked out.", user.Id);
- return RedirectToPage("./Lockout");
- }
- else
- {
- _logger.LogWarning("Invalid authenticator code entered for user with ID '{UserId}'.", user.Id);
- ModelState.AddModelError(string.Empty, "Invalid authenticator code.");
- return Page();
- }
- }
- }
-}
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/LoginWithRecoveryCode.cshtml b/Kemkas.Web/Areas/Identity/Pages/Account/LoginWithRecoveryCode.cshtml
deleted file mode 100644
index 0d44e37..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/LoginWithRecoveryCode.cshtml
+++ /dev/null
@@ -1,29 +0,0 @@
-@page
-@model LoginWithRecoveryCodeModel
-@{
- ViewData["Title"] = "Recovery code verification";
-}
-
-
@ViewData["Title"]
-
-
- You have requested to log in with a recovery code. This login will not be remembered until you provide
- an authenticator app code at log in or disable 2FA and log in again.
-
-
-
-
-
-
-
-@section Scripts {
-
-}
\ No newline at end of file
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/LoginWithRecoveryCode.cshtml.cs b/Kemkas.Web/Areas/Identity/Pages/Account/LoginWithRecoveryCode.cshtml.cs
deleted file mode 100644
index 847208b..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/LoginWithRecoveryCode.cshtml.cs
+++ /dev/null
@@ -1,113 +0,0 @@
-// 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.ComponentModel.DataAnnotations;
-using System.Threading.Tasks;
-using Microsoft.AspNetCore.Authorization;
-using Kemkas.Web.Db.Models;
-using Microsoft.AspNetCore.Identity;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.AspNetCore.Mvc.RazorPages;
-using Microsoft.Extensions.Logging;
-namespace Kemkas.Web.Areas.Identity.Pages.Account
-{
- public class LoginWithRecoveryCodeModel : PageModel
- {
- private readonly SignInManager _signInManager;
- private readonly UserManager _userManager;
- private readonly ILogger _logger;
-
- public LoginWithRecoveryCodeModel(
- SignInManager signInManager,
- UserManager userManager,
- ILogger logger)
- {
- _signInManager = signInManager;
- _userManager = userManager;
- _logger = logger;
- }
-
- ///
- /// 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.
- ///
- [BindProperty]
- public InputModel Input { get; set; }
-
- ///
- /// 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.
- ///
- public string ReturnUrl { get; set; }
-
- ///
- /// 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.
- ///
- public class InputModel
- {
- ///
- /// 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.
- ///
- [BindProperty]
- [Required]
- [DataType(DataType.Text)]
- [Display(Name = "Recovery Code")]
- public string RecoveryCode { get; set; }
- }
-
- public async Task OnGetAsync(string returnUrl = null)
- {
- // Ensure the user has gone through the username & password screen first
- var user = await _signInManager.GetTwoFactorAuthenticationUserAsync();
- if (user == null)
- {
- throw new InvalidOperationException($"Unable to load two-factor authentication user.");
- }
-
- ReturnUrl = returnUrl;
-
- return Page();
- }
-
- public async Task OnPostAsync(string returnUrl = null)
- {
- if (!ModelState.IsValid)
- {
- return Page();
- }
-
- var user = await _signInManager.GetTwoFactorAuthenticationUserAsync();
- if (user == null)
- {
- throw new InvalidOperationException($"Unable to load two-factor authentication user.");
- }
-
- var recoveryCode = Input.RecoveryCode.Replace(" ", string.Empty);
-
- var result = await _signInManager.TwoFactorRecoveryCodeSignInAsync(recoveryCode);
-
- var userId = await _userManager.GetUserIdAsync(user);
-
- if (result.Succeeded)
- {
- _logger.LogInformation("User with ID '{UserId}' logged in with a recovery code.", user.Id);
- return LocalRedirect(returnUrl ?? Url.Content("~/"));
- }
- if (result.IsLockedOut)
- {
- _logger.LogWarning("User account locked out.");
- return RedirectToPage("./Lockout");
- }
- else
- {
- _logger.LogWarning("Invalid recovery code entered for user with ID '{UserId}' ", user.Id);
- ModelState.AddModelError(string.Empty, "Invalid recovery code entered.");
- return Page();
- }
- }
- }
-}
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/Logout.cshtml b/Kemkas.Web/Areas/Identity/Pages/Account/Logout.cshtml
deleted file mode 100644
index cad49d7..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/Logout.cshtml
+++ /dev/null
@@ -1,21 +0,0 @@
-@page
-@model LogoutModel
-@{
- ViewData["Title"] = "Log out";
-}
-
-
-
You have successfully logged out of the application.
- }
- }
-
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/Logout.cshtml.cs b/Kemkas.Web/Areas/Identity/Pages/Account/Logout.cshtml.cs
deleted file mode 100644
index 815f4d0..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/Logout.cshtml.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-// 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.Threading.Tasks;
-using Microsoft.AspNetCore.Authorization;
-using Kemkas.Web.Db.Models;
-using Microsoft.AspNetCore.Identity;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.AspNetCore.Mvc.RazorPages;
-using Microsoft.Extensions.Logging;
-
-namespace Kemkas.Web.Areas.Identity.Pages.Account
-{
- [IgnoreAntiforgeryToken(Order = 1001)]
- public class LogoutModel : PageModel
- {
- private readonly SignInManager _signInManager;
- private readonly ILogger _logger;
-
- public LogoutModel(SignInManager signInManager, ILogger logger)
- {
- _signInManager = signInManager;
- _logger = logger;
- }
-
- public async Task OnPost(string returnUrl = null)
- {
- await _signInManager.SignOutAsync();
- _logger.LogInformation("User logged out.");
- if (returnUrl != null)
- {
- return LocalRedirect(returnUrl);
- }
- else
- {
- // This needs to be a redirect so that the browser performs a new
- // request and the identity for the user gets updated.
- return RedirectToPage();
- }
- }
- }
-}
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/ChangePassword.cshtml b/Kemkas.Web/Areas/Identity/Pages/Account/Manage/ChangePassword.cshtml
deleted file mode 100644
index 073603a..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/ChangePassword.cshtml
+++ /dev/null
@@ -1,36 +0,0 @@
-@page
-@model ChangePasswordModel
-@{
- ViewData["Title"] = "Change password";
- ViewData["ActivePage"] = ManageNavPages.ChangePassword;
-}
-
-
@ViewData["Title"]
-
-
-
-
-
-
-
-@section Scripts {
-
-}
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/ChangePassword.cshtml.cs b/Kemkas.Web/Areas/Identity/Pages/Account/Manage/ChangePassword.cshtml.cs
deleted file mode 100644
index c14d1f1..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/ChangePassword.cshtml.cs
+++ /dev/null
@@ -1,128 +0,0 @@
-// 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.ComponentModel.DataAnnotations;
-using System.Threading.Tasks;
-using Kemkas.Web.Db.Models;
-using Microsoft.AspNetCore.Identity;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.AspNetCore.Mvc.RazorPages;
-using Microsoft.Extensions.Logging;
-
-namespace Kemkas.Web.Areas.Identity.Pages.Account.Manage
-{
- public class ChangePasswordModel : PageModel
- {
- private readonly UserManager _userManager;
- private readonly SignInManager _signInManager;
- private readonly ILogger _logger;
-
- public ChangePasswordModel(
- UserManager userManager,
- SignInManager signInManager,
- ILogger logger)
- {
- _userManager = userManager;
- _signInManager = signInManager;
- _logger = logger;
- }
-
- ///
- /// 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.
- ///
- [BindProperty]
- public InputModel Input { get; set; }
-
- ///
- /// 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.
- ///
- [TempData]
- public string StatusMessage { get; set; }
-
- ///
- /// 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.
- ///
- public class InputModel
- {
- ///
- /// 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.
- ///
- [Required]
- [DataType(DataType.Password)]
- [Display(Name = "Current password")]
- public string OldPassword { get; set; }
-
- ///
- /// 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.
- ///
- [Required]
- [StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", MinimumLength = 6)]
- [DataType(DataType.Password)]
- [Display(Name = "New password")]
- public string NewPassword { get; set; }
-
- ///
- /// 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.
- ///
- [DataType(DataType.Password)]
- [Display(Name = "Confirm new password")]
- [Compare("NewPassword", ErrorMessage = "The new password and confirmation password do not match.")]
- public string ConfirmPassword { get; set; }
- }
-
- public async Task OnGetAsync()
- {
- var user = await _userManager.GetUserAsync(User);
- if (user == null)
- {
- return NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
- }
-
- var hasPassword = await _userManager.HasPasswordAsync(user);
- if (!hasPassword)
- {
- return RedirectToPage("./SetPassword");
- }
-
- return Page();
- }
-
- public async Task OnPostAsync()
- {
- if (!ModelState.IsValid)
- {
- return Page();
- }
-
- var user = await _userManager.GetUserAsync(User);
- if (user == null)
- {
- return NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
- }
-
- var changePasswordResult = await _userManager.ChangePasswordAsync(user, Input.OldPassword, Input.NewPassword);
- if (!changePasswordResult.Succeeded)
- {
- foreach (var error in changePasswordResult.Errors)
- {
- ModelState.AddModelError(string.Empty, error.Description);
- }
- return Page();
- }
-
- await _signInManager.RefreshSignInAsync(user);
- _logger.LogInformation("User changed their password successfully.");
- StatusMessage = "Your password has been changed.";
-
- return RedirectToPage();
- }
- }
-}
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/DeletePersonalData.cshtml b/Kemkas.Web/Areas/Identity/Pages/Account/Manage/DeletePersonalData.cshtml
deleted file mode 100644
index cecdd1d..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/DeletePersonalData.cshtml
+++ /dev/null
@@ -1,33 +0,0 @@
-@page
-@model DeletePersonalDataModel
-@{
- ViewData["Title"] = "Delete Personal Data";
- ViewData["ActivePage"] = ManageNavPages.PersonalData;
-}
-
-
@ViewData["Title"]
-
-
-
- Deleting this data will permanently remove your account, and this cannot be recovered.
-
-
-
-
-
-
-
-@section Scripts {
-
-}
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/DeletePersonalData.cshtml.cs b/Kemkas.Web/Areas/Identity/Pages/Account/Manage/DeletePersonalData.cshtml.cs
deleted file mode 100644
index 03e1d55..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/DeletePersonalData.cshtml.cs
+++ /dev/null
@@ -1,104 +0,0 @@
-// 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.ComponentModel.DataAnnotations;
-using System.Threading.Tasks;
-using Kemkas.Web.Db.Models;
-using Microsoft.AspNetCore.Identity;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.AspNetCore.Mvc.RazorPages;
-using Microsoft.Extensions.Logging;
-
-namespace Kemkas.Web.Areas.Identity.Pages.Account.Manage
-{
- public class DeletePersonalDataModel : PageModel
- {
- private readonly UserManager _userManager;
- private readonly SignInManager _signInManager;
- private readonly ILogger _logger;
-
- public DeletePersonalDataModel(
- UserManager userManager,
- SignInManager signInManager,
- ILogger logger)
- {
- _userManager = userManager;
- _signInManager = signInManager;
- _logger = logger;
- }
-
- ///
- /// 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.
- ///
- [BindProperty]
- public InputModel Input { get; set; }
-
- ///
- /// 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.
- ///
- public class InputModel
- {
- ///
- /// 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.
- ///
- [Required]
- [DataType(DataType.Password)]
- public string Password { get; set; }
- }
-
- ///
- /// 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.
- ///
- public bool RequirePassword { get; set; }
-
- public async Task OnGet()
- {
- var user = await _userManager.GetUserAsync(User);
- if (user == null)
- {
- return NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
- }
-
- RequirePassword = await _userManager.HasPasswordAsync(user);
- return Page();
- }
-
- public async Task OnPostAsync()
- {
- var user = await _userManager.GetUserAsync(User);
- if (user == null)
- {
- return NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
- }
-
- RequirePassword = await _userManager.HasPasswordAsync(user);
- if (RequirePassword)
- {
- if (!await _userManager.CheckPasswordAsync(user, Input.Password))
- {
- ModelState.AddModelError(string.Empty, "Incorrect password.");
- return Page();
- }
- }
-
- var result = await _userManager.DeleteAsync(user);
- var userId = await _userManager.GetUserIdAsync(user);
- if (!result.Succeeded)
- {
- throw new InvalidOperationException($"Unexpected error occurred deleting user.");
- }
-
- await _signInManager.SignOutAsync();
-
- _logger.LogInformation("User with ID '{UserId}' deleted themselves.", userId);
-
- return Redirect("~/");
- }
- }
-}
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/Disable2fa.cshtml b/Kemkas.Web/Areas/Identity/Pages/Account/Manage/Disable2fa.cshtml
deleted file mode 100644
index 31ecb7e..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/Disable2fa.cshtml
+++ /dev/null
@@ -1,25 +0,0 @@
-@page
-@model Disable2faModel
-@{
- ViewData["Title"] = "Disable two-factor authentication (2FA)";
- ViewData["ActivePage"] = ManageNavPages.TwoFactorAuthentication;
-}
-
-
-
@ViewData["Title"]
-
-
-
- This action only disables 2FA.
-
-
- Disabling 2FA does not change the keys used in authenticator apps. If you wish to change the key
- used in an authenticator app you should reset your authenticator keys.
-
-
-
-
-
-
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/Disable2fa.cshtml.cs b/Kemkas.Web/Areas/Identity/Pages/Account/Manage/Disable2fa.cshtml.cs
deleted file mode 100644
index 501391d..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/Disable2fa.cshtml.cs
+++ /dev/null
@@ -1,70 +0,0 @@
-// 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.Threading.Tasks;
-using Kemkas.Web.Db.Models;
-using Microsoft.AspNetCore.Identity;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.AspNetCore.Mvc.RazorPages;
-using Microsoft.Extensions.Logging;
-
-namespace Kemkas.Web.Areas.Identity.Pages.Account.Manage
-{
- public class Disable2faModel : PageModel
- {
- private readonly UserManager _userManager;
- private readonly ILogger _logger;
-
- public Disable2faModel(
- UserManager userManager,
- ILogger logger)
- {
- _userManager = userManager;
- _logger = logger;
- }
-
- ///
- /// 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.
- ///
- [TempData]
- public string StatusMessage { get; set; }
-
- public async Task OnGet()
- {
- var user = await _userManager.GetUserAsync(User);
- if (user == null)
- {
- return NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
- }
-
- if (!await _userManager.GetTwoFactorEnabledAsync(user))
- {
- throw new InvalidOperationException($"Cannot disable 2FA for user as it's not currently enabled.");
- }
-
- return Page();
- }
-
- public async Task OnPostAsync()
- {
- var user = await _userManager.GetUserAsync(User);
- if (user == null)
- {
- return NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
- }
-
- var disable2faResult = await _userManager.SetTwoFactorEnabledAsync(user, false);
- if (!disable2faResult.Succeeded)
- {
- throw new InvalidOperationException($"Unexpected error occurred disabling 2FA.");
- }
-
- _logger.LogInformation("User with ID '{UserId}' has disabled 2fa.", _userManager.GetUserId(User));
- StatusMessage = "2fa has been disabled. You can reenable 2fa when you setup an authenticator app";
- return RedirectToPage("./TwoFactorAuthentication");
- }
- }
-}
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/DownloadPersonalData.cshtml b/Kemkas.Web/Areas/Identity/Pages/Account/Manage/DownloadPersonalData.cshtml
deleted file mode 100644
index 93f631f..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/DownloadPersonalData.cshtml
+++ /dev/null
@@ -1,12 +0,0 @@
-@page
-@model DownloadPersonalDataModel
-@{
- ViewData["Title"] = "Download Your Data";
- ViewData["ActivePage"] = ManageNavPages.PersonalData;
-}
-
-
@ViewData["Title"]
-
-@section Scripts {
-
-}
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/DownloadPersonalData.cshtml.cs b/Kemkas.Web/Areas/Identity/Pages/Account/Manage/DownloadPersonalData.cshtml.cs
deleted file mode 100644
index ca6a362..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/DownloadPersonalData.cshtml.cs
+++ /dev/null
@@ -1,68 +0,0 @@
-// 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.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Text.Json;
-using System.Threading.Tasks;
-using Kemkas.Web.Db.Models;
-using Microsoft.AspNetCore.Identity;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.AspNetCore.Mvc.RazorPages;
-using Microsoft.Extensions.Logging;
-
-namespace Kemkas.Web.Areas.Identity.Pages.Account.Manage
-{
- public class DownloadPersonalDataModel : PageModel
- {
- private readonly UserManager _userManager;
- private readonly ILogger _logger;
-
- public DownloadPersonalDataModel(
- UserManager userManager,
- ILogger logger)
- {
- _userManager = userManager;
- _logger = logger;
- }
-
- public IActionResult OnGet()
- {
- return NotFound();
- }
-
- public async Task OnPostAsync()
- {
- var user = await _userManager.GetUserAsync(User);
- if (user == null)
- {
- return NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
- }
-
- _logger.LogInformation("User with ID '{UserId}' asked for their personal data.", _userManager.GetUserId(User));
-
- // Only include personal data for download
- var personalData = new Dictionary();
- var personalDataProps = typeof(ApplicationUser).GetProperties().Where(
- prop => Attribute.IsDefined(prop, typeof(PersonalDataAttribute)));
- foreach (var p in personalDataProps)
- {
- personalData.Add(p.Name, p.GetValue(user)?.ToString() ?? "null");
- }
-
- var logins = await _userManager.GetLoginsAsync(user);
- foreach (var l in logins)
- {
- personalData.Add($"{l.LoginProvider} external login provider key", l.ProviderKey);
- }
-
- personalData.Add($"Authenticator Key", await _userManager.GetAuthenticatorKeyAsync(user));
-
- Response.Headers.TryAdd("Content-Disposition", "attachment; filename=PersonalData.json");
- return new FileContentResult(JsonSerializer.SerializeToUtf8Bytes(personalData), "application/json");
- }
- }
-}
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/Email.cshtml b/Kemkas.Web/Areas/Identity/Pages/Account/Manage/Email.cshtml
deleted file mode 100644
index f3278e9..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/Email.cshtml
+++ /dev/null
@@ -1,44 +0,0 @@
-@page
-@model EmailModel
-@{
- ViewData["Title"] = "Manage Email";
- ViewData["ActivePage"] = ManageNavPages.Email;
-}
-
-
@ViewData["Title"]
-
-
-
-
-
-
-
-@section Scripts {
-
-}
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/Email.cshtml.cs b/Kemkas.Web/Areas/Identity/Pages/Account/Manage/Email.cshtml.cs
deleted file mode 100644
index e9c24fc..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/Email.cshtml.cs
+++ /dev/null
@@ -1,172 +0,0 @@
-// 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.ComponentModel.DataAnnotations;
-using System.Text;
-using System.Text.Encodings.Web;
-using System.Threading.Tasks;
-using Kemkas.Web.Db.Models;
-using Microsoft.AspNetCore.Identity;
-using Microsoft.AspNetCore.Identity.UI.Services;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.AspNetCore.Mvc.RazorPages;
-using Microsoft.AspNetCore.WebUtilities;
-
-namespace Kemkas.Web.Areas.Identity.Pages.Account.Manage
-{
- public class EmailModel : PageModel
- {
- private readonly UserManager _userManager;
- private readonly SignInManager _signInManager;
- private readonly IEmailSender _emailSender;
-
- public EmailModel(
- UserManager userManager,
- SignInManager signInManager,
- IEmailSender emailSender)
- {
- _userManager = userManager;
- _signInManager = signInManager;
- _emailSender = emailSender;
- }
-
- ///
- /// 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.
- ///
- public string Email { get; set; }
-
- ///
- /// 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.
- ///
- public bool IsEmailConfirmed { get; set; }
-
- ///
- /// 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.
- ///
- [TempData]
- public string StatusMessage { get; set; }
-
- ///
- /// 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.
- ///
- [BindProperty]
- public InputModel Input { get; set; }
-
- ///
- /// 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.
- ///
- public class InputModel
- {
- ///
- /// 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.
- ///
- [Required]
- [EmailAddress]
- [Display(Name = "New email")]
- public string NewEmail { get; set; }
- }
-
- private async Task LoadAsync(ApplicationUser user)
- {
- var email = await _userManager.GetEmailAsync(user);
- Email = email;
-
- Input = new InputModel
- {
- NewEmail = email,
- };
-
- IsEmailConfirmed = await _userManager.IsEmailConfirmedAsync(user);
- }
-
- public async Task OnGetAsync()
- {
- var user = await _userManager.GetUserAsync(User);
- if (user == null)
- {
- return NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
- }
-
- await LoadAsync(user);
- return Page();
- }
-
- public async Task OnPostChangeEmailAsync()
- {
- var user = await _userManager.GetUserAsync(User);
- if (user == null)
- {
- return NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
- }
-
- if (!ModelState.IsValid)
- {
- await LoadAsync(user);
- return Page();
- }
-
- var email = await _userManager.GetEmailAsync(user);
- if (Input.NewEmail != email)
- {
- var userId = await _userManager.GetUserIdAsync(user);
- var code = await _userManager.GenerateChangeEmailTokenAsync(user, Input.NewEmail);
- code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code));
- var callbackUrl = Url.Page(
- "/Account/ConfirmEmailChange",
- pageHandler: null,
- values: new { area = "Identity", userId = userId, email = Input.NewEmail, code = code },
- protocol: Request.Scheme);
- await _emailSender.SendEmailAsync(
- Input.NewEmail,
- "Confirm your email",
- $"Please confirm your account by clicking here.");
-
- StatusMessage = "Confirmation link to change email sent. Please check your email.";
- return RedirectToPage();
- }
-
- StatusMessage = "Your email is unchanged.";
- return RedirectToPage();
- }
-
- public async Task OnPostSendVerificationEmailAsync()
- {
- var user = await _userManager.GetUserAsync(User);
- if (user == null)
- {
- return NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
- }
-
- if (!ModelState.IsValid)
- {
- await LoadAsync(user);
- return Page();
- }
-
- var userId = await _userManager.GetUserIdAsync(user);
- var email = await _userManager.GetEmailAsync(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(
- email,
- "Confirm your email",
- $"Please confirm your account by clicking here.");
-
- StatusMessage = "Verification email sent. Please check your email.";
- return RedirectToPage();
- }
- }
-}
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/EnableAuthenticator.cshtml b/Kemkas.Web/Areas/Identity/Pages/Account/Manage/EnableAuthenticator.cshtml
deleted file mode 100644
index d73358a..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/EnableAuthenticator.cshtml
+++ /dev/null
@@ -1,56 +0,0 @@
-@page
-@model EnableAuthenticatorModel
-@{
- ViewData["Title"] = "Configure authenticator app";
- ViewData["ActivePage"] = ManageNavPages.TwoFactorAuthentication;
-}
-
-
-
@ViewData["Title"]
-
-
To use an authenticator app go through the following steps:
-
-
-
- Download a two-factor authenticator app like Microsoft Authenticator for
- Android and
- iOS or
- Google Authenticator for
- Android and
- iOS.
-
-
-
-
Scan the QR Code or enter this key @Model.SharedKey into your two factor authenticator app. Spaces and casing do not matter.
- Once you have scanned the QR code or input the key above, your two factor authentication app will provide you
- with a unique code. Enter the code in the confirmation box below.
-
-
-
-
-
-
-
-
-
-
-@section Scripts {
-
-
-
-
-}
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/EnableAuthenticator.cshtml.cs b/Kemkas.Web/Areas/Identity/Pages/Account/Manage/EnableAuthenticator.cshtml.cs
deleted file mode 100644
index 919bb97..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/EnableAuthenticator.cshtml.cs
+++ /dev/null
@@ -1,189 +0,0 @@
-// 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.ComponentModel.DataAnnotations;
-using System.Globalization;
-using System.Linq;
-using System.Text;
-using System.Text.Encodings.Web;
-using System.Threading.Tasks;
-using Kemkas.Web.Db.Models;
-using Microsoft.AspNetCore.Identity;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.AspNetCore.Mvc.RazorPages;
-using Microsoft.Extensions.Logging;
-
-namespace Kemkas.Web.Areas.Identity.Pages.Account.Manage
-{
- public class EnableAuthenticatorModel : PageModel
- {
- private readonly UserManager _userManager;
- private readonly ILogger _logger;
- private readonly UrlEncoder _urlEncoder;
-
- private const string AuthenticatorUriFormat = "otpauth://totp/{0}:{1}?secret={2}&issuer={0}&digits=6";
-
- public EnableAuthenticatorModel(
- UserManager userManager,
- ILogger logger,
- UrlEncoder urlEncoder)
- {
- _userManager = userManager;
- _logger = logger;
- _urlEncoder = urlEncoder;
- }
-
- ///
- /// 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.
- ///
- public string SharedKey { get; set; }
-
- ///
- /// 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.
- ///
- public string AuthenticatorUri { get; set; }
-
- ///
- /// 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.
- ///
- [TempData]
- public string[] RecoveryCodes { get; set; }
-
- ///
- /// 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.
- ///
- [TempData]
- public string StatusMessage { get; set; }
-
- ///
- /// 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.
- ///
- [BindProperty]
- public InputModel Input { get; set; }
-
- ///
- /// 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.
- ///
- public class InputModel
- {
- ///
- /// 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.
- ///
- [Required]
- [StringLength(7, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", MinimumLength = 6)]
- [DataType(DataType.Text)]
- [Display(Name = "Verification Code")]
- public string Code { get; set; }
- }
-
- public async Task OnGetAsync()
- {
- var user = await _userManager.GetUserAsync(User);
- if (user == null)
- {
- return NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
- }
-
- await LoadSharedKeyAndQrCodeUriAsync(user);
-
- return Page();
- }
-
- public async Task OnPostAsync()
- {
- var user = await _userManager.GetUserAsync(User);
- if (user == null)
- {
- return NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
- }
-
- if (!ModelState.IsValid)
- {
- await LoadSharedKeyAndQrCodeUriAsync(user);
- return Page();
- }
-
- // Strip spaces and hyphens
- var verificationCode = Input.Code.Replace(" ", string.Empty).Replace("-", string.Empty);
-
- var is2faTokenValid = await _userManager.VerifyTwoFactorTokenAsync(
- user, _userManager.Options.Tokens.AuthenticatorTokenProvider, verificationCode);
-
- if (!is2faTokenValid)
- {
- ModelState.AddModelError("Input.Code", "Verification code is invalid.");
- await LoadSharedKeyAndQrCodeUriAsync(user);
- return Page();
- }
-
- await _userManager.SetTwoFactorEnabledAsync(user, true);
- var userId = await _userManager.GetUserIdAsync(user);
- _logger.LogInformation("User with ID '{UserId}' has enabled 2FA with an authenticator app.", userId);
-
- StatusMessage = "Your authenticator app has been verified.";
-
- if (await _userManager.CountRecoveryCodesAsync(user) == 0)
- {
- var recoveryCodes = await _userManager.GenerateNewTwoFactorRecoveryCodesAsync(user, 10);
- RecoveryCodes = recoveryCodes.ToArray();
- return RedirectToPage("./ShowRecoveryCodes");
- }
- else
- {
- return RedirectToPage("./TwoFactorAuthentication");
- }
- }
-
- private async Task LoadSharedKeyAndQrCodeUriAsync(ApplicationUser user)
- {
- // Load the authenticator key & QR code URI to display on the form
- var unformattedKey = await _userManager.GetAuthenticatorKeyAsync(user);
- if (string.IsNullOrEmpty(unformattedKey))
- {
- await _userManager.ResetAuthenticatorKeyAsync(user);
- unformattedKey = await _userManager.GetAuthenticatorKeyAsync(user);
- }
-
- SharedKey = FormatKey(unformattedKey);
-
- var email = await _userManager.GetEmailAsync(user);
- AuthenticatorUri = GenerateQrCodeUri(email, unformattedKey);
- }
-
- private string FormatKey(string unformattedKey)
- {
- var result = new StringBuilder();
- int currentPosition = 0;
- while (currentPosition + 4 < unformattedKey.Length)
- {
- result.Append(unformattedKey.AsSpan(currentPosition, 4)).Append(' ');
- currentPosition += 4;
- }
- if (currentPosition < unformattedKey.Length)
- {
- result.Append(unformattedKey.AsSpan(currentPosition));
- }
-
- return result.ToString().ToLowerInvariant();
- }
-
- private string GenerateQrCodeUri(string email, string unformattedKey)
- {
- return string.Format(
- CultureInfo.InvariantCulture,
- AuthenticatorUriFormat,
- _urlEncoder.Encode("Kemkas"),
- _urlEncoder.Encode(email),
- unformattedKey);
- }
- }
-}
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/ExternalLogins.cshtml b/Kemkas.Web/Areas/Identity/Pages/Account/Manage/ExternalLogins.cshtml
deleted file mode 100644
index 7c397e5..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/ExternalLogins.cshtml
+++ /dev/null
@@ -1,53 +0,0 @@
-@page
-@model ExternalLoginsModel
-@{
- ViewData["Title"] = "Manage your external logins";
- ViewData["ActivePage"] = ManageNavPages.ExternalLogins;
-}
-
-
-@if (Model.CurrentLogins?.Count > 0)
-{
-
Registered Logins
-
-
- @foreach (var login in Model.CurrentLogins)
- {
-
-
-
-}
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/ExternalLogins.cshtml.cs b/Kemkas.Web/Areas/Identity/Pages/Account/Manage/ExternalLogins.cshtml.cs
deleted file mode 100644
index 206d16d..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/ExternalLogins.cshtml.cs
+++ /dev/null
@@ -1,142 +0,0 @@
-// 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.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Kemkas.Web.Db.Models;
-using Microsoft.AspNetCore.Authentication;
-using Microsoft.AspNetCore.Identity;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.AspNetCore.Mvc.RazorPages;
-
-namespace Kemkas.Web.Areas.Identity.Pages.Account.Manage
-{
- public class ExternalLoginsModel : PageModel
- {
- private readonly UserManager _userManager;
- private readonly SignInManager _signInManager;
- private readonly IUserStore _userStore;
-
- public ExternalLoginsModel(
- UserManager userManager,
- SignInManager signInManager,
- IUserStore userStore)
- {
- _userManager = userManager;
- _signInManager = signInManager;
- _userStore = userStore;
- }
-
- ///
- /// 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.
- ///
- public IList CurrentLogins { get; set; }
-
- ///
- /// 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.
- ///
- public IList OtherLogins { get; set; }
-
- ///
- /// 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.
- ///
- public bool ShowRemoveButton { get; set; }
-
- ///
- /// 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.
- ///
- [TempData]
- public string StatusMessage { get; set; }
-
- public async Task OnGetAsync()
- {
- var user = await _userManager.GetUserAsync(User);
- if (user == null)
- {
- return NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
- }
-
- CurrentLogins = await _userManager.GetLoginsAsync(user);
- OtherLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync())
- .Where(auth => CurrentLogins.All(ul => auth.Name != ul.LoginProvider))
- .ToList();
-
- string passwordHash = null;
- if (_userStore is IUserPasswordStore userPasswordStore)
- {
- passwordHash = await userPasswordStore.GetPasswordHashAsync(user, HttpContext.RequestAborted);
- }
-
- ShowRemoveButton = passwordHash != null || CurrentLogins.Count > 1;
- return Page();
- }
-
- public async Task OnPostRemoveLoginAsync(string loginProvider, string providerKey)
- {
- var user = await _userManager.GetUserAsync(User);
- if (user == null)
- {
- return NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
- }
-
- var result = await _userManager.RemoveLoginAsync(user, loginProvider, providerKey);
- if (!result.Succeeded)
- {
- StatusMessage = "The external login was not removed.";
- return RedirectToPage();
- }
-
- await _signInManager.RefreshSignInAsync(user);
- StatusMessage = "The external login was removed.";
- return RedirectToPage();
- }
-
- public async Task OnPostLinkLoginAsync(string provider)
- {
- // Clear the existing external cookie to ensure a clean login process
- await HttpContext.SignOutAsync(IdentityConstants.ExternalScheme);
-
- // Request a redirect to the external login provider to link a login for the current user
- var redirectUrl = Url.Page("./ExternalLogins", pageHandler: "LinkLoginCallback");
- var properties = _signInManager.ConfigureExternalAuthenticationProperties(provider, redirectUrl, _userManager.GetUserId(User));
- return new ChallengeResult(provider, properties);
- }
-
- public async Task OnGetLinkLoginCallbackAsync()
- {
- var user = await _userManager.GetUserAsync(User);
- if (user == null)
- {
- return NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
- }
-
- var userId = await _userManager.GetUserIdAsync(user);
- var info = await _signInManager.GetExternalLoginInfoAsync(userId);
- if (info == null)
- {
- throw new InvalidOperationException($"Unexpected error occurred loading external login info.");
- }
-
- var result = await _userManager.AddLoginAsync(user, info);
- if (!result.Succeeded)
- {
- StatusMessage = "The external login was not added. External logins can only be associated with one account.";
- return RedirectToPage();
- }
-
- // Clear the existing external cookie to ensure a clean login process
- await HttpContext.SignOutAsync(IdentityConstants.ExternalScheme);
-
- StatusMessage = "The external login was added.";
- return RedirectToPage();
- }
- }
-}
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/GenerateRecoveryCodes.cshtml b/Kemkas.Web/Areas/Identity/Pages/Account/Manage/GenerateRecoveryCodes.cshtml
deleted file mode 100644
index 91e1d01..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/GenerateRecoveryCodes.cshtml
+++ /dev/null
@@ -1,27 +0,0 @@
-@page
-@model GenerateRecoveryCodesModel
-@{
- ViewData["Title"] = "Generate two-factor authentication (2FA) recovery codes";
- ViewData["ActivePage"] = ManageNavPages.TwoFactorAuthentication;
-}
-
-
-
@ViewData["Title"]
-
-
-
- Put these codes in a safe place.
-
-
- If you lose your device and don't have the recovery codes you will lose access to your account.
-
-
- Generating new recovery codes does not change the keys used in authenticator apps. If you wish to change the key
- used in an authenticator app you should reset your authenticator keys.
-
-
-
-
-
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/GenerateRecoveryCodes.cshtml.cs b/Kemkas.Web/Areas/Identity/Pages/Account/Manage/GenerateRecoveryCodes.cshtml.cs
deleted file mode 100644
index 5c88d0d..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/GenerateRecoveryCodes.cshtml.cs
+++ /dev/null
@@ -1,83 +0,0 @@
-// 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.Threading.Tasks;
-using Kemkas.Web.Db.Models;
-using Microsoft.AspNetCore.Identity;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.AspNetCore.Mvc.RazorPages;
-using Microsoft.Extensions.Logging;
-
-namespace Kemkas.Web.Areas.Identity.Pages.Account.Manage
-{
- public class GenerateRecoveryCodesModel : PageModel
- {
- private readonly UserManager _userManager;
- private readonly ILogger _logger;
-
- public GenerateRecoveryCodesModel(
- UserManager userManager,
- ILogger logger)
- {
- _userManager = userManager;
- _logger = logger;
- }
-
- ///
- /// 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.
- ///
- [TempData]
- public string[] RecoveryCodes { get; set; }
-
- ///
- /// 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.
- ///
- [TempData]
- public string StatusMessage { get; set; }
-
- public async Task OnGetAsync()
- {
- var user = await _userManager.GetUserAsync(User);
- if (user == null)
- {
- return NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
- }
-
- var isTwoFactorEnabled = await _userManager.GetTwoFactorEnabledAsync(user);
- if (!isTwoFactorEnabled)
- {
- throw new InvalidOperationException($"Cannot generate recovery codes for user because they do not have 2FA enabled.");
- }
-
- return Page();
- }
-
- public async Task OnPostAsync()
- {
- var user = await _userManager.GetUserAsync(User);
- if (user == null)
- {
- return NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
- }
-
- var isTwoFactorEnabled = await _userManager.GetTwoFactorEnabledAsync(user);
- var userId = await _userManager.GetUserIdAsync(user);
- if (!isTwoFactorEnabled)
- {
- throw new InvalidOperationException($"Cannot generate recovery codes for user as they do not have 2FA enabled.");
- }
-
- var recoveryCodes = await _userManager.GenerateNewTwoFactorRecoveryCodesAsync(user, 10);
- RecoveryCodes = recoveryCodes.ToArray();
-
- _logger.LogInformation("User with ID '{UserId}' has generated new 2FA recovery codes.", userId);
- StatusMessage = "You have generated new recovery codes.";
- return RedirectToPage("./ShowRecoveryCodes");
- }
- }
-}
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/Index.cshtml b/Kemkas.Web/Areas/Identity/Pages/Account/Manage/Index.cshtml
deleted file mode 100644
index 94b669d..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/Index.cshtml
+++ /dev/null
@@ -1,30 +0,0 @@
-@page
-@model IndexModel
-@{
- ViewData["Title"] = "Profile";
- ViewData["ActivePage"] = ManageNavPages.Index;
-}
-
-
@ViewData["Title"]
-
-
-
-
-
-
-
-@section Scripts {
-
-}
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/Index.cshtml.cs b/Kemkas.Web/Areas/Identity/Pages/Account/Manage/Index.cshtml.cs
deleted file mode 100644
index 6b02614..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/Index.cshtml.cs
+++ /dev/null
@@ -1,119 +0,0 @@
-// 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.ComponentModel.DataAnnotations;
-using System.Text.Encodings.Web;
-using System.Threading.Tasks;
-using Kemkas.Web.Db.Models;
-using Microsoft.AspNetCore.Identity;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.AspNetCore.Mvc.RazorPages;
-
-namespace Kemkas.Web.Areas.Identity.Pages.Account.Manage
-{
- public class IndexModel : PageModel
- {
- private readonly UserManager _userManager;
- private readonly SignInManager _signInManager;
-
- public IndexModel(
- UserManager userManager,
- SignInManager signInManager)
- {
- _userManager = userManager;
- _signInManager = signInManager;
- }
-
- ///
- /// 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.
- ///
- public string Username { get; set; }
-
- ///
- /// 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.
- ///
- [TempData]
- public string StatusMessage { get; set; }
-
- ///
- /// 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.
- ///
- [BindProperty]
- public InputModel Input { get; set; }
-
- ///
- /// 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.
- ///
- public class InputModel
- {
- ///
- /// 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.
- ///
- [Phone]
- [Display(Name = "Phone number")]
- public string PhoneNumber { get; set; }
- }
-
- private async Task LoadAsync(ApplicationUser user)
- {
- var userName = await _userManager.GetUserNameAsync(user);
- var phoneNumber = await _userManager.GetPhoneNumberAsync(user);
-
- Username = userName;
-
- Input = new InputModel
- {
- PhoneNumber = phoneNumber
- };
- }
-
- public async Task OnGetAsync()
- {
- var user = await _userManager.GetUserAsync(User);
- if (user == null)
- {
- return NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
- }
-
- await LoadAsync(user);
- return Page();
- }
-
- public async Task OnPostAsync()
- {
- var user = await _userManager.GetUserAsync(User);
- if (user == null)
- {
- return NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
- }
-
- if (!ModelState.IsValid)
- {
- await LoadAsync(user);
- return Page();
- }
-
- var phoneNumber = await _userManager.GetPhoneNumberAsync(user);
- if (Input.PhoneNumber != phoneNumber)
- {
- var setPhoneResult = await _userManager.SetPhoneNumberAsync(user, Input.PhoneNumber);
- if (!setPhoneResult.Succeeded)
- {
- StatusMessage = "Unexpected error when trying to set phone number.";
- return RedirectToPage();
- }
- }
-
- await _signInManager.RefreshSignInAsync(user);
- StatusMessage = "Your profile has been updated";
- return RedirectToPage();
- }
- }
-}
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/ManageNavPages.cs b/Kemkas.Web/Areas/Identity/Pages/Account/Manage/ManageNavPages.cs
deleted file mode 100644
index bdd2851..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/ManageNavPages.cs
+++ /dev/null
@@ -1,123 +0,0 @@
-// 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 Microsoft.AspNetCore.Mvc.Rendering;
-
-namespace Kemkas.Web.Areas.Identity.Pages.Account.Manage
-{
- ///
- /// 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.
- ///
- public static class ManageNavPages
- {
- ///
- /// 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.
- ///
- public static string Index => "Index";
-
- ///
- /// 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.
- ///
- public static string Email => "Email";
-
- ///
- /// 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.
- ///
- public static string ChangePassword => "ChangePassword";
-
- ///
- /// 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.
- ///
- public static string DownloadPersonalData => "DownloadPersonalData";
-
- ///
- /// 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.
- ///
- public static string DeletePersonalData => "DeletePersonalData";
-
- ///
- /// 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.
- ///
- public static string ExternalLogins => "ExternalLogins";
-
- ///
- /// 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.
- ///
- public static string PersonalData => "PersonalData";
-
- ///
- /// 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.
- ///
- public static string TwoFactorAuthentication => "TwoFactorAuthentication";
-
- ///
- /// 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.
- ///
- public static string IndexNavClass(ViewContext viewContext) => PageNavClass(viewContext, Index);
-
- ///
- /// 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.
- ///
- public static string EmailNavClass(ViewContext viewContext) => PageNavClass(viewContext, Email);
-
- ///
- /// 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.
- ///
- public static string ChangePasswordNavClass(ViewContext viewContext) => PageNavClass(viewContext, ChangePassword);
-
- ///
- /// 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.
- ///
- public static string DownloadPersonalDataNavClass(ViewContext viewContext) => PageNavClass(viewContext, DownloadPersonalData);
-
- ///
- /// 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.
- ///
- public static string DeletePersonalDataNavClass(ViewContext viewContext) => PageNavClass(viewContext, DeletePersonalData);
-
- ///
- /// 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.
- ///
- public static string ExternalLoginsNavClass(ViewContext viewContext) => PageNavClass(viewContext, ExternalLogins);
-
- ///
- /// 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.
- ///
- public static string PersonalDataNavClass(ViewContext viewContext) => PageNavClass(viewContext, PersonalData);
-
- ///
- /// 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.
- ///
- public static string TwoFactorAuthenticationNavClass(ViewContext viewContext) => PageNavClass(viewContext, TwoFactorAuthentication);
-
- ///
- /// 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.
- ///
- public static string PageNavClass(ViewContext viewContext, string page)
- {
- var activePage = viewContext.ViewData["ActivePage"] as string
- ?? System.IO.Path.GetFileNameWithoutExtension(viewContext.ActionDescriptor.DisplayName);
- return string.Equals(activePage, page, StringComparison.OrdinalIgnoreCase) ? "active" : null;
- }
- }
-}
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/PersonalData.cshtml b/Kemkas.Web/Areas/Identity/Pages/Account/Manage/PersonalData.cshtml
deleted file mode 100644
index 0835493..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/PersonalData.cshtml
+++ /dev/null
@@ -1,27 +0,0 @@
-@page
-@model PersonalDataModel
-@{
- ViewData["Title"] = "Personal Data";
- ViewData["ActivePage"] = ManageNavPages.PersonalData;
-}
-
-
@ViewData["Title"]
-
-
-
-
Your account contains personal data that you have given us. This page allows you to download or delete that data.
-
- Deleting this data will permanently remove your account, and this cannot be recovered.
-
-
-@section Scripts {
-
-}
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/PersonalData.cshtml.cs b/Kemkas.Web/Areas/Identity/Pages/Account/Manage/PersonalData.cshtml.cs
deleted file mode 100644
index ed290d3..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/PersonalData.cshtml.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-using System;
-using System.Threading.Tasks;
-using Kemkas.Web.Db.Models;
-using Microsoft.AspNetCore.Identity;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.AspNetCore.Mvc.RazorPages;
-using Microsoft.Extensions.Logging;
-
-namespace Kemkas.Web.Areas.Identity.Pages.Account.Manage
-{
- public class PersonalDataModel : PageModel
- {
- private readonly UserManager _userManager;
- private readonly ILogger _logger;
-
- public PersonalDataModel(
- UserManager userManager,
- ILogger logger)
- {
- _userManager = userManager;
- _logger = logger;
- }
-
- public async Task OnGet()
- {
- var user = await _userManager.GetUserAsync(User);
- if (user == null)
- {
- return NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
- }
-
- return Page();
- }
- }
-}
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/ResetAuthenticator.cshtml b/Kemkas.Web/Areas/Identity/Pages/Account/Manage/ResetAuthenticator.cshtml
deleted file mode 100644
index f3297e0..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/ResetAuthenticator.cshtml
+++ /dev/null
@@ -1,24 +0,0 @@
-@page
-@model ResetAuthenticatorModel
-@{
- ViewData["Title"] = "Reset authenticator key";
- ViewData["ActivePage"] = ManageNavPages.TwoFactorAuthentication;
-}
-
-
-
@ViewData["Title"]
-
-
-
- If you reset your authenticator key your authenticator app will not work until you reconfigure it.
-
-
- This process disables 2FA until you verify your authenticator app.
- If you do not complete your authenticator app configuration you may lose access to your account.
-
-
-
-
-
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/ResetAuthenticator.cshtml.cs b/Kemkas.Web/Areas/Identity/Pages/Account/Manage/ResetAuthenticator.cshtml.cs
deleted file mode 100644
index 01cc4f7..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/ResetAuthenticator.cshtml.cs
+++ /dev/null
@@ -1,68 +0,0 @@
-// 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.Threading.Tasks;
-using Kemkas.Web.Db.Models;
-using Microsoft.AspNetCore.Identity;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.AspNetCore.Mvc.RazorPages;
-using Microsoft.Extensions.Logging;
-
-namespace Kemkas.Web.Areas.Identity.Pages.Account.Manage
-{
- public class ResetAuthenticatorModel : PageModel
- {
- private readonly UserManager _userManager;
- private readonly SignInManager _signInManager;
- private readonly ILogger _logger;
-
- public ResetAuthenticatorModel(
- UserManager userManager,
- SignInManager signInManager,
- ILogger logger)
- {
- _userManager = userManager;
- _signInManager = signInManager;
- _logger = logger;
- }
-
- ///
- /// 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.
- ///
- [TempData]
- public string StatusMessage { get; set; }
-
- public async Task OnGet()
- {
- var user = await _userManager.GetUserAsync(User);
- if (user == null)
- {
- return NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
- }
-
- return Page();
- }
-
- public async Task OnPostAsync()
- {
- var user = await _userManager.GetUserAsync(User);
- if (user == null)
- {
- return NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
- }
-
- await _userManager.SetTwoFactorEnabledAsync(user, false);
- await _userManager.ResetAuthenticatorKeyAsync(user);
- var userId = await _userManager.GetUserIdAsync(user);
- _logger.LogInformation("User with ID '{UserId}' has reset their authentication app key.", user.Id);
-
- await _signInManager.RefreshSignInAsync(user);
- StatusMessage = "Your authenticator app key has been reset, you will need to configure your authenticator app using the new key.";
-
- return RedirectToPage("./EnableAuthenticator");
- }
- }
-}
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/SetPassword.cshtml b/Kemkas.Web/Areas/Identity/Pages/Account/Manage/SetPassword.cshtml
deleted file mode 100644
index a4ba058..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/SetPassword.cshtml
+++ /dev/null
@@ -1,35 +0,0 @@
-@page
-@model SetPasswordModel
-@{
- ViewData["Title"] = "Set password";
- ViewData["ActivePage"] = ManageNavPages.ChangePassword;
-}
-
-
Set your password
-
-
- You do not have a local username/password for this site. Add a local
- account so you can log in without an external login.
-
-
-
-
-
-
-
-@section Scripts {
-
-}
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/SetPassword.cshtml.cs b/Kemkas.Web/Areas/Identity/Pages/Account/Manage/SetPassword.cshtml.cs
deleted file mode 100644
index bfc6726..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/SetPassword.cshtml.cs
+++ /dev/null
@@ -1,115 +0,0 @@
-// 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.ComponentModel.DataAnnotations;
-using System.Threading.Tasks;
-using Kemkas.Web.Db.Models;
-using Microsoft.AspNetCore.Identity;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.AspNetCore.Mvc.RazorPages;
-
-namespace Kemkas.Web.Areas.Identity.Pages.Account.Manage
-{
- public class SetPasswordModel : PageModel
- {
- private readonly UserManager _userManager;
- private readonly SignInManager _signInManager;
-
- public SetPasswordModel(
- UserManager userManager,
- SignInManager signInManager)
- {
- _userManager = userManager;
- _signInManager = signInManager;
- }
-
- ///
- /// 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.
- ///
- [BindProperty]
- public InputModel Input { get; set; }
-
- ///
- /// 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.
- ///
- [TempData]
- public string StatusMessage { get; set; }
-
- ///
- /// 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.
- ///
- public class InputModel
- {
- ///
- /// 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.
- ///
- [Required]
- [StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", MinimumLength = 6)]
- [DataType(DataType.Password)]
- [Display(Name = "New password")]
- public string NewPassword { get; set; }
-
- ///
- /// 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.
- ///
- [DataType(DataType.Password)]
- [Display(Name = "Confirm new password")]
- [Compare("NewPassword", ErrorMessage = "The new password and confirmation password do not match.")]
- public string ConfirmPassword { get; set; }
- }
-
- public async Task OnGetAsync()
- {
- var user = await _userManager.GetUserAsync(User);
- if (user == null)
- {
- return NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
- }
-
- var hasPassword = await _userManager.HasPasswordAsync(user);
-
- if (hasPassword)
- {
- return RedirectToPage("./ChangePassword");
- }
-
- return Page();
- }
-
- public async Task OnPostAsync()
- {
- if (!ModelState.IsValid)
- {
- return Page();
- }
-
- var user = await _userManager.GetUserAsync(User);
- if (user == null)
- {
- return NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
- }
-
- var addPasswordResult = await _userManager.AddPasswordAsync(user, Input.NewPassword);
- if (!addPasswordResult.Succeeded)
- {
- foreach (var error in addPasswordResult.Errors)
- {
- ModelState.AddModelError(string.Empty, error.Description);
- }
- return Page();
- }
-
- await _signInManager.RefreshSignInAsync(user);
- StatusMessage = "Your password has been set.";
-
- return RedirectToPage();
- }
- }
-}
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/ShowRecoveryCodes.cshtml b/Kemkas.Web/Areas/Identity/Pages/Account/Manage/ShowRecoveryCodes.cshtml
deleted file mode 100644
index 49a8518..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/ShowRecoveryCodes.cshtml
+++ /dev/null
@@ -1,25 +0,0 @@
-@page
-@model ShowRecoveryCodesModel
-@{
- ViewData["Title"] = "Recovery codes";
- ViewData["ActivePage"] = "TwoFactorAuthentication";
-}
-
-
-
@ViewData["Title"]
-
-
- Put these codes in a safe place.
-
-
- If you lose your device and don't have the recovery codes you will lose access to your account.
-
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/ShowRecoveryCodes.cshtml.cs b/Kemkas.Web/Areas/Identity/Pages/Account/Manage/ShowRecoveryCodes.cshtml.cs
deleted file mode 100644
index f26dc8b..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/ShowRecoveryCodes.cshtml.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-// 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 Kemkas.Web.Db.Models;
-using Microsoft.AspNetCore.Identity;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.AspNetCore.Mvc.RazorPages;
-using Microsoft.Extensions.Logging;
-
-namespace Kemkas.Web.Areas.Identity.Pages.Account.Manage
-{
- ///
- /// 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.
- ///
- public class ShowRecoveryCodesModel : PageModel
- {
- ///
- /// 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.
- ///
- [TempData]
- public string[] RecoveryCodes { get; set; }
-
- ///
- /// 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.
- ///
- [TempData]
- public string StatusMessage { get; set; }
-
- ///
- /// 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.
- ///
- public IActionResult OnGet()
- {
- if (RecoveryCodes == null || RecoveryCodes.Length == 0)
- {
- return RedirectToPage("./TwoFactorAuthentication");
- }
-
- return Page();
- }
- }
-}
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/TwoFactorAuthentication.cshtml b/Kemkas.Web/Areas/Identity/Pages/Account/Manage/TwoFactorAuthentication.cshtml
deleted file mode 100644
index 6db5b32..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/TwoFactorAuthentication.cshtml
+++ /dev/null
@@ -1,71 +0,0 @@
-@page
-@using Microsoft.AspNetCore.Http.Features
-@model TwoFactorAuthenticationModel
-@{
- ViewData["Title"] = "Two-factor authentication (2FA)";
- ViewData["ActivePage"] = ManageNavPages.TwoFactorAuthentication;
-}
-
-
-
- Privacy and cookie policy have not been accepted.
-
You must accept the policy before you can enable two factor authentication.
-
- }
-}
-
-@section Scripts {
-
-}
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/TwoFactorAuthentication.cshtml.cs b/Kemkas.Web/Areas/Identity/Pages/Account/Manage/TwoFactorAuthentication.cshtml.cs
deleted file mode 100644
index d6fcdde..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/TwoFactorAuthentication.cshtml.cs
+++ /dev/null
@@ -1,90 +0,0 @@
-// 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.Threading.Tasks;
-using Kemkas.Web.Db.Models;
-using Microsoft.AspNetCore.Identity;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.AspNetCore.Mvc.RazorPages;
-using Microsoft.Extensions.Logging;
-
-namespace Kemkas.Web.Areas.Identity.Pages.Account.Manage
-{
- public class TwoFactorAuthenticationModel : PageModel
- {
- private readonly UserManager _userManager;
- private readonly SignInManager _signInManager;
- private readonly ILogger _logger;
-
- public TwoFactorAuthenticationModel(
- UserManager userManager, SignInManager signInManager, ILogger logger)
- {
- _userManager = userManager;
- _signInManager = signInManager;
- _logger = logger;
- }
-
- ///
- /// 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.
- ///
- public bool HasAuthenticator { get; set; }
-
- ///
- /// 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.
- ///
- public int RecoveryCodesLeft { get; set; }
-
- ///
- /// 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.
- ///
- [BindProperty]
- public bool Is2faEnabled { get; set; }
-
- ///
- /// 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.
- ///
- public bool IsMachineRemembered { get; set; }
-
- ///
- /// 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.
- ///
- [TempData]
- public string StatusMessage { get; set; }
-
- public async Task OnGetAsync()
- {
- var user = await _userManager.GetUserAsync(User);
- if (user == null)
- {
- return NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
- }
-
- HasAuthenticator = await _userManager.GetAuthenticatorKeyAsync(user) != null;
- Is2faEnabled = await _userManager.GetTwoFactorEnabledAsync(user);
- IsMachineRemembered = await _signInManager.IsTwoFactorClientRememberedAsync(user);
- RecoveryCodesLeft = await _userManager.CountRecoveryCodesAsync(user);
-
- return Page();
- }
-
- public async Task OnPostAsync()
- {
- var user = await _userManager.GetUserAsync(User);
- if (user == null)
- {
- return NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
- }
-
- await _signInManager.ForgetTwoFactorClientAsync();
- StatusMessage = "The current browser has been forgotten. When you login again from this browser you will be prompted for your 2fa code.";
- return RedirectToPage();
- }
- }
-}
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/_Layout.cshtml b/Kemkas.Web/Areas/Identity/Pages/Account/Manage/_Layout.cshtml
deleted file mode 100644
index fb77735..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/_Layout.cshtml
+++ /dev/null
@@ -1,29 +0,0 @@
-@{
- if (ViewData.TryGetValue("ParentLayout", out var parentLayout) && parentLayout != null)
- {
- Layout = parentLayout.ToString();
- }
- else
- {
- Layout = "/Areas/Identity/Pages/_Layout.cshtml";
- }
-}
-
-
-
-@section Scripts {
-
-}
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/Register.cshtml.cs b/Kemkas.Web/Areas/Identity/Pages/Account/Register.cshtml.cs
deleted file mode 100644
index bd1bff2..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/Register.cshtml.cs
+++ /dev/null
@@ -1,203 +0,0 @@
-// 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.Collections.Generic;
-using System.ComponentModel.DataAnnotations;
-using System.Linq;
-using System.Text;
-using System.Text.Encodings.Web;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.AspNetCore.Authentication;
-using Microsoft.AspNetCore.Authorization;
-using Kemkas.Web.Db.Models;
-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.Logging;
-
-namespace Kemkas.Web.Areas.Identity.Pages.Account
-{
- public class RegisterModel : PageModel
- {
- private readonly SignInManager _signInManager;
- private readonly UserManager _userManager;
- private readonly IUserStore _userStore;
- private readonly IUserEmailStore _emailStore;
- private readonly ILogger _logger;
- private readonly IEmailSender _emailSender;
- private readonly IWebHostEnvironment _environment;
-
- public RegisterModel(
- UserManager userManager,
- IUserStore userStore,
- SignInManager signInManager,
- ILogger logger,
- IEmailSender emailSender,
- IWebHostEnvironment environment)
- {
- _userManager = userManager;
- _userStore = userStore;
- _emailStore = GetEmailStore();
- _signInManager = signInManager;
- _logger = logger;
- _emailSender = emailSender;
- _environment = environment;
- }
-
- ///
- /// 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.
- ///
- [BindProperty]
- public InputModel Input { get; set; }
-
- ///
- /// 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.
- ///
- public string ReturnUrl { get; set; }
-
- ///
- /// 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.
- ///
- public IList ExternalLogins { get; set; }
-
- ///
- /// 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.
- ///
- public class InputModel
- {
- ///
- /// 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.
- ///
- [Required]
- [EmailAddress]
- [Display(Name = "Email")]
- public string Email { get; set; }
-
- ///
- /// 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.
- ///
- [Required]
- [StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", MinimumLength = 6)]
- [DataType(DataType.Password)]
- [Display(Name = "Password")]
- public string Password { get; set; }
-
- ///
- /// 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.
- ///
- [DataType(DataType.Password)]
- [Display(Name = "Confirm password")]
- [Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
- public string ConfirmPassword { get; set; }
- }
-
-
- public async Task OnGetAsync(string returnUrl = null)
- {
- ReturnUrl = returnUrl;
- ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList();
- // Disable not yet approved external login providers in production
- if (!_environment.IsDevelopment())
- {
- ExternalLogins = ExternalLogins.Where(el => el.Name == "Discord").ToList();
- }
- }
-
- public async Task OnPostAsync(string returnUrl = null)
- {
- returnUrl ??= Url.Content("~/");
- ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList();
- // Disable not yet approved external login providers in production
- if (!_environment.IsDevelopment())
- {
- ExternalLogins = ExternalLogins.Where(el => el.Name == "Discord").ToList();
- }
- if (!ModelState.IsValid)
- {
- return Page();
- }
- var user = CreateUser();
-
- await _userStore.SetUserNameAsync(user, Input.Email, CancellationToken.None);
- await _emailStore.SetEmailAsync(user, Input.Email, CancellationToken.None);
- var result = await _userManager.CreateAsync(user, Input.Password);
-
- if (!result.Succeeded)
- {
- foreach (var error in result.Errors)
- {
- ModelState.AddModelError(string.Empty, error.Description);
- }
-
- return Page();
- }
-
- _logger.LogInformation("User created a new account with password.");
-
- 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, returnUrl = returnUrl },
- protocol: Request.Scheme);
-
- try
- {
- await _emailSender.SendEmailAsync(Input.Email, "Confirm your email",
- $"Please confirm your account by clicking here.");
- }
- catch
- {
- await _userManager.DeleteAsync(user); // Delete user to free up the email address for a second registration.
- ModelState.AddModelError("Input.Email", "Failed to send account confirmation email!");
- return Page();
- }
-
- if (_userManager.Options.SignIn.RequireConfirmedAccount)
- {
- return RedirectToPage("RegisterConfirmation",
- new { email = Input.Email, returnUrl = returnUrl });
- }
-
- await _signInManager.SignInAsync(user, isPersistent: false);
- return LocalRedirect(returnUrl);
- }
-
- private ApplicationUser CreateUser()
- {
- try
- {
- return Activator.CreateInstance();
- }
- catch
- {
- throw new InvalidOperationException($"Can't create an instance of '{nameof(ApplicationUser)}'. " +
- $"Ensure that '{nameof(ApplicationUser)}' is not an abstract class and has a parameterless constructor, or alternatively " +
- $"override the register page in /Areas/Identity/Pages/Account/Register.cshtml");
- }
- }
-
- private IUserEmailStore GetEmailStore()
- {
- if (!_userManager.SupportsUserEmail)
- {
- throw new NotSupportedException("The default UI requires a user store with email support.");
- }
- return (IUserEmailStore)_userStore;
- }
- }
-}
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/RegisterConfirmation.cshtml b/Kemkas.Web/Areas/Identity/Pages/Account/RegisterConfirmation.cshtml
deleted file mode 100644
index 04321a5..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/RegisterConfirmation.cshtml
+++ /dev/null
@@ -1,11 +0,0 @@
-@page
-@model RegisterConfirmationModel
-@{
- ViewData["Title"] = "Register confirmation";
-}
-
-
@ViewData["Title"]
-
- Please check your email to confirm your account.
-
-
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/RegisterConfirmation.cshtml.cs b/Kemkas.Web/Areas/Identity/Pages/Account/RegisterConfirmation.cshtml.cs
deleted file mode 100644
index e507813..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/RegisterConfirmation.cshtml.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-// 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 Kemkas.Web.Db.Models;
-using Microsoft.AspNetCore.Identity;
-using Microsoft.AspNetCore.Identity.UI.Services;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.AspNetCore.Mvc.RazorPages;
-using Microsoft.AspNetCore.WebUtilities;
-
-namespace Kemkas.Web.Areas.Identity.Pages.Account
-{
- [AllowAnonymous]
- public class RegisterConfirmationModel : PageModel
- {
- private readonly UserManager _userManager;
- private readonly IEmailSender _sender;
-
- public RegisterConfirmationModel(UserManager userManager, IEmailSender sender)
- {
- _userManager = userManager;
- _sender = sender;
- }
-
- ///
- /// 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.
- ///
- public string Email { get; set; }
-
- public async Task OnGetAsync(string email, string returnUrl = null)
- {
- if (email == null)
- {
- return RedirectToPage("/Index");
- }
-
- var user = await _userManager.FindByEmailAsync(email);
- if (user == null)
- {
- return NotFound($"Unable to load user with email '{email}'.");
- }
-
- Email = email;
-
- return Page();
- }
- }
-}
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/ResendEmailConfirmation.cshtml b/Kemkas.Web/Areas/Identity/Pages/Account/ResendEmailConfirmation.cshtml
deleted file mode 100644
index d457b6b..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/ResendEmailConfirmation.cshtml
+++ /dev/null
@@ -1,26 +0,0 @@
-@page
-@model ResendEmailConfirmationModel
-@{
- ViewData["Title"] = "Resend email confirmation";
-}
-
-
@ViewData["Title"]
-
Enter your email.
-
-
-
-
-
-
-
-@section Scripts {
-
-}
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/ResendEmailConfirmation.cshtml.cs b/Kemkas.Web/Areas/Identity/Pages/Account/ResendEmailConfirmation.cshtml.cs
deleted file mode 100644
index e231984..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/ResendEmailConfirmation.cshtml.cs
+++ /dev/null
@@ -1,89 +0,0 @@
-// 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.ComponentModel.DataAnnotations;
-using System.Text;
-using System.Text.Encodings.Web;
-using System.Threading.Tasks;
-using Microsoft.AspNetCore.Authorization;
-using Kemkas.Web.Db.Models;
-using Microsoft.AspNetCore.Identity;
-using Microsoft.AspNetCore.Identity.UI.Services;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.AspNetCore.Mvc.RazorPages;
-using Microsoft.AspNetCore.WebUtilities;
-
-namespace Kemkas.Web.Areas.Identity.Pages.Account
-{
- [AllowAnonymous]
- public class ResendEmailConfirmationModel : PageModel
- {
- private readonly UserManager _userManager;
- private readonly IEmailSender _emailSender;
-
- public ResendEmailConfirmationModel(UserManager userManager, IEmailSender emailSender)
- {
- _userManager = userManager;
- _emailSender = emailSender;
- }
-
- ///
- /// 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.
- ///
- [BindProperty]
- public InputModel Input { get; set; }
-
- ///
- /// 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.
- ///
- public class InputModel
- {
- ///
- /// 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.
- ///
- [Required]
- [EmailAddress]
- public string Email { get; set; }
- }
-
- public void OnGet()
- {
- }
-
- public async Task OnPostAsync()
- {
- if (!ModelState.IsValid)
- {
- return Page();
- }
-
- var user = await _userManager.FindByEmailAsync(Input.Email);
- if (user == null)
- {
- ModelState.AddModelError(string.Empty, "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 { userId = userId, code = code },
- protocol: Request.Scheme);
- await _emailSender.SendEmailAsync(
- Input.Email,
- "Confirm your email",
- $"Please confirm your account by clicking here.");
-
- ModelState.AddModelError(string.Empty, "Verification email sent. Please check your email.");
- return Page();
- }
- }
-}
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/ResetPassword.cshtml b/Kemkas.Web/Areas/Identity/Pages/Account/ResetPassword.cshtml
deleted file mode 100644
index e430d01..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/ResetPassword.cshtml
+++ /dev/null
@@ -1,37 +0,0 @@
-@page
-@model ResetPasswordModel
-@{
- ViewData["Title"] = "Reset password";
-}
-
-
@ViewData["Title"]
-
Reset your password.
-
-
-
-
-
-
-
-@section Scripts {
-
-}
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/ResetPassword.cshtml.cs b/Kemkas.Web/Areas/Identity/Pages/Account/ResetPassword.cshtml.cs
deleted file mode 100644
index a0130e6..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/ResetPassword.cshtml.cs
+++ /dev/null
@@ -1,118 +0,0 @@
-// 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.ComponentModel.DataAnnotations;
-using System.Text;
-using System.Threading.Tasks;
-using Microsoft.AspNetCore.Authorization;
-using Kemkas.Web.Db.Models;
-using Microsoft.AspNetCore.Identity;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.AspNetCore.Mvc.RazorPages;
-using Microsoft.AspNetCore.WebUtilities;
-
-namespace Kemkas.Web.Areas.Identity.Pages.Account
-{
- public class ResetPasswordModel : PageModel
- {
- private readonly UserManager _userManager;
-
- public ResetPasswordModel(UserManager userManager)
- {
- _userManager = userManager;
- }
-
- ///
- /// 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.
- ///
- [BindProperty]
- public InputModel Input { get; set; }
-
- ///
- /// 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.
- ///
- public class InputModel
- {
- ///
- /// 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.
- ///
- [Required]
- [EmailAddress]
- public string Email { get; set; }
-
- ///
- /// 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.
- ///
- [Required]
- [StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", MinimumLength = 6)]
- [DataType(DataType.Password)]
- public string Password { get; set; }
-
- ///
- /// 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.
- ///
- [DataType(DataType.Password)]
- [Display(Name = "Confirm password")]
- [Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
- public string ConfirmPassword { get; set; }
-
- ///
- /// 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.
- ///
- [Required]
- public string Code { get; set; }
-
- }
-
- public IActionResult OnGet(string code = null)
- {
- if (code == null)
- {
- return BadRequest("A code must be supplied for password reset.");
- }
- else
- {
- Input = new InputModel
- {
- Code = Encoding.UTF8.GetString(WebEncoders.Base64UrlDecode(code))
- };
- return Page();
- }
- }
-
- public async Task OnPostAsync()
- {
- if (!ModelState.IsValid)
- {
- return Page();
- }
-
- var user = await _userManager.FindByEmailAsync(Input.Email);
- if (user == null)
- {
- // Don't reveal that the user does not exist
- return RedirectToPage("./ResetPasswordConfirmation");
- }
-
- var result = await _userManager.ResetPasswordAsync(user, Input.Code, Input.Password);
- if (result.Succeeded)
- {
- return RedirectToPage("./ResetPasswordConfirmation");
- }
-
- foreach (var error in result.Errors)
- {
- ModelState.AddModelError(string.Empty, error.Description);
- }
- return Page();
- }
- }
-}
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/ResetPasswordConfirmation.cshtml b/Kemkas.Web/Areas/Identity/Pages/Account/ResetPasswordConfirmation.cshtml
deleted file mode 100644
index c52552f..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/ResetPasswordConfirmation.cshtml
+++ /dev/null
@@ -1,10 +0,0 @@
-@page
-@model ResetPasswordConfirmationModel
-@{
- ViewData["Title"] = "Reset password confirmation";
-}
-
-
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/ResetPasswordConfirmation.cshtml.cs b/Kemkas.Web/Areas/Identity/Pages/Account/ResetPasswordConfirmation.cshtml.cs
deleted file mode 100644
index 5af61a2..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/ResetPasswordConfirmation.cshtml.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-// 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.Authorization;
-using Microsoft.AspNetCore.Mvc.RazorPages;
-
-namespace Kemkas.Web.Areas.Identity.Pages.Account
-{
- ///
- /// 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.
- ///
- [AllowAnonymous]
- public class ResetPasswordConfirmationModel : PageModel
- {
- ///
- /// 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.
- ///
- public void OnGet()
- {
- }
- }
-}
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/_StatusMessage.cshtml b/Kemkas.Web/Areas/Identity/Pages/Account/_StatusMessage.cshtml
deleted file mode 100644
index c898543..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/_StatusMessage.cshtml
+++ /dev/null
@@ -1,10 +0,0 @@
-@model string
-
-@if (!String.IsNullOrEmpty(Model))
-{
- var statusMessageClass = Model.StartsWith("Error") ? "danger" : "success";
-
-
- @Model
-
-}
diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/_ViewImports.cshtml b/Kemkas.Web/Areas/Identity/Pages/Account/_ViewImports.cshtml
deleted file mode 100644
index ec2ac95..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Account/_ViewImports.cshtml
+++ /dev/null
@@ -1 +0,0 @@
-@using Kemkas.Web.Areas.Identity.Pages.Account
\ No newline at end of file
diff --git a/Kemkas.Web/Areas/Identity/Pages/Error.cshtml b/Kemkas.Web/Areas/Identity/Pages/Error.cshtml
deleted file mode 100644
index b1f3143..0000000
--- a/Kemkas.Web/Areas/Identity/Pages/Error.cshtml
+++ /dev/null
@@ -1,23 +0,0 @@
-@page
-@model ErrorModel
-@{
- ViewData["Title"] = "Error";
-}
-
-
Error.
-
An error occurred while processing your request.
-
-@if (Model.ShowRequestId)
-{
-
- Request ID:@Model.RequestId
-
-}
-
-
Development Mode
-
- Swapping to Development environment will display more detailed information about the error that occurred.
-
-
- Development environment should not be enabled in deployed applications, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the ASPNETCORE_ENVIRONMENT environment variable to Development, and restarting the application.
-