mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Redo .NET Identity as it was not working.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
// Canary Islands Computer Museum Website
|
// Canary Islands Computer Museum Website
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
@@ -28,8 +28,12 @@
|
|||||||
// Copyright © 2003-2018 Natalia Portillo
|
// Copyright © 2003-2018 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
|
using Cicm.Database.Models;
|
||||||
using cicm_web.Areas.Identity;
|
using cicm_web.Areas.Identity;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.AspNetCore.Identity;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
[assembly: HostingStartup(typeof(IdentityHostingStartup))]
|
[assembly: HostingStartup(typeof(IdentityHostingStartup))]
|
||||||
|
|
||||||
@@ -39,7 +43,15 @@ namespace cicm_web.Areas.Identity
|
|||||||
{
|
{
|
||||||
public void Configure(IWebHostBuilder builder)
|
public void Configure(IWebHostBuilder builder)
|
||||||
{
|
{
|
||||||
builder.ConfigureServices((context, services) => { });
|
builder.ConfigureServices((context, services) =>
|
||||||
|
{
|
||||||
|
services.AddDbContext<cicmContext>(options => options
|
||||||
|
.UseLazyLoadingProxies()
|
||||||
|
.UseMySql("server=localhost;port=3306;user=cicm;password=cicmpass;database=cicm"));
|
||||||
|
|
||||||
|
services.AddDefaultIdentity<IdentityUser>().AddRoles<IdentityRole>()
|
||||||
|
.AddEntityFrameworkStores<cicmContext>();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
// Canary Islands Computer Museum Website
|
// Canary Islands Computer Museum Website
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
ViewData["Title"] = "Confirm email";
|
ViewData["Title"] = "Confirm email";
|
||||||
}
|
}
|
||||||
|
|
||||||
<h2>@ViewData["Title"]</h2>
|
<h1>@ViewData["Title"]</h1>
|
||||||
<div>
|
<div>
|
||||||
<p>
|
<p>
|
||||||
Thank you for confirming your email.
|
Thank you for confirming your email.
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
// Canary Islands Computer Museum Website
|
// Canary Islands Computer Museum Website
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
ViewData["Title"] = "Register";
|
ViewData["Title"] = "Register";
|
||||||
}
|
}
|
||||||
|
|
||||||
<h2>@ViewData["Title"]</h2>
|
<h1>@ViewData["Title"]</h1>
|
||||||
<h4>Associate your @Model.LoginProvider account.</h4>
|
<h4>Associate your @Model.LoginProvider account.</h4>
|
||||||
<hr />
|
<hr />
|
||||||
|
|
||||||
@@ -47,14 +47,24 @@
|
|||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
<form asp-page-handler="Confirmation" asp-route-returnUrl="@Model.ReturnUrl" method="post">
|
<form asp-page-handler="Confirmation"
|
||||||
<div asp-validation-summary="All" class="text-danger"></div>
|
asp-route-returnUrl="@Model.ReturnUrl"
|
||||||
|
method="post">
|
||||||
|
<div asp-validation-summary="All"
|
||||||
|
class="text-danger">
|
||||||
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label asp-for="Input.Email"></label>
|
<label asp-for="Input.Email"></label>
|
||||||
<input asp-for="Input.Email" class="form-control" />
|
<input asp-for="Input.Email"
|
||||||
<span asp-validation-for="Input.Email" class="text-danger"></span>
|
class="form-control" />
|
||||||
|
<span asp-validation-for="Input.Email"
|
||||||
|
class="text-danger">
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="btn btn-default">Register</button>
|
<button class="btn btn-primary"
|
||||||
|
type="submit">
|
||||||
|
Register
|
||||||
|
</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -62,4 +72,3 @@
|
|||||||
@section Scripts {
|
@section Scripts {
|
||||||
<partial name="_ValidationScriptsPartial" />
|
<partial name="_ValidationScriptsPartial" />
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
// Canary Islands Computer Museum Website
|
// Canary Islands Computer Museum Website
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -35,19 +35,27 @@
|
|||||||
ViewData["Title"] = "Forgot your password?";
|
ViewData["Title"] = "Forgot your password?";
|
||||||
}
|
}
|
||||||
|
|
||||||
<h2>@ViewData["Title"]</h2>
|
<h1>@ViewData["Title"]</h1>
|
||||||
<h4>Enter your email.</h4>
|
<h4>Enter your email.</h4>
|
||||||
<hr />
|
<hr />
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
<form method="post">
|
<form method="post">
|
||||||
<div asp-validation-summary="All" class="text-danger"></div>
|
<div asp-validation-summary="All"
|
||||||
|
class="text-danger">
|
||||||
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label asp-for="Input.Email"></label>
|
<label asp-for="Input.Email"></label>
|
||||||
<input asp-for="Input.Email" class="form-control" />
|
<input asp-for="Input.Email"
|
||||||
<span asp-validation-for="Input.Email" class="text-danger"></span>
|
class="form-control" />
|
||||||
|
<span asp-validation-for="Input.Email"
|
||||||
|
class="text-danger">
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="btn btn-default">Submit</button>
|
<button class="btn btn-primary"
|
||||||
|
type="submit">
|
||||||
|
Submit
|
||||||
|
</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
// Canary Islands Computer Museum Website
|
// Canary Islands Computer Museum Website
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
@@ -56,24 +56,22 @@ namespace cicm_web.Areas.Identity.Pages.Account
|
|||||||
|
|
||||||
public async Task<IActionResult> OnPostAsync()
|
public async Task<IActionResult> OnPostAsync()
|
||||||
{
|
{
|
||||||
if(ModelState.IsValid)
|
if(!ModelState.IsValid) return Page();
|
||||||
{
|
|
||||||
IdentityUser user = await _userManager.FindByEmailAsync(Input.Email);
|
|
||||||
if(user == null || !await _userManager.IsEmailConfirmedAsync(user))
|
|
||||||
return RedirectToPage("./ForgotPasswordConfirmation");
|
|
||||||
|
|
||||||
// For more information on how to enable account confirmation and password reset please
|
|
||||||
// visit https://go.microsoft.com/fwlink/?LinkID=532713
|
|
||||||
string code = await _userManager.GeneratePasswordResetTokenAsync(user);
|
|
||||||
string callbackUrl = Url.Page("/Account/ResetPassword", null, new {code}, Request.Scheme);
|
|
||||||
|
|
||||||
await _emailSender.SendEmailAsync(Input.Email, "Reset Password",
|
|
||||||
$"Please reset your password by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a>.");
|
|
||||||
|
|
||||||
|
IdentityUser 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");
|
return RedirectToPage("./ForgotPasswordConfirmation");
|
||||||
}
|
|
||||||
|
|
||||||
return Page();
|
// For more information on how to enable account confirmation and password reset please
|
||||||
|
// visit https://go.microsoft.com/fwlink/?LinkID=532713
|
||||||
|
string code = await _userManager.GeneratePasswordResetTokenAsync(user);
|
||||||
|
string callbackUrl = Url.Page("/Account/ResetPassword", null, new {code}, Request.Scheme);
|
||||||
|
|
||||||
|
await _emailSender.SendEmailAsync(Input.Email, "Reset Password",
|
||||||
|
$"Please reset your password by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a>.");
|
||||||
|
|
||||||
|
return RedirectToPage("./ForgotPasswordConfirmation");
|
||||||
}
|
}
|
||||||
|
|
||||||
public class InputModel
|
public class InputModel
|
||||||
|
|||||||
@@ -35,8 +35,7 @@
|
|||||||
ViewData["Title"] = "Forgot password confirmation";
|
ViewData["Title"] = "Forgot password confirmation";
|
||||||
}
|
}
|
||||||
|
|
||||||
<h2>@ViewData["Title"]</h2>
|
<h1>@ViewData["Title"]</h1>
|
||||||
<p>
|
<p>
|
||||||
Please check your email to reset your password.
|
Please check your email to reset your password.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
// Canary Islands Computer Museum Website
|
// Canary Islands Computer Museum Website
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
// Canary Islands Computer Museum Website
|
// Canary Islands Computer Museum Website
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -30,29 +30,39 @@
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
}
|
}
|
||||||
@page
|
@page
|
||||||
|
@using Microsoft.AspNetCore.Authentication
|
||||||
@model LoginModel
|
@model LoginModel
|
||||||
|
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "Log in";
|
ViewData["Title"] = "Log in";
|
||||||
}
|
}
|
||||||
|
|
||||||
<h2>@ViewData["Title"]</h2>
|
<h1>@ViewData["Title"]</h1>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
<section>
|
<section>
|
||||||
<form method="post">
|
<form id="account"
|
||||||
|
method="post">
|
||||||
<h4>Use a local account to log in.</h4>
|
<h4>Use a local account to log in.</h4>
|
||||||
<hr />
|
<hr />
|
||||||
<div asp-validation-summary="All" class="text-danger"></div>
|
<div asp-validation-summary="All"
|
||||||
|
class="text-danger">
|
||||||
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label asp-for="Input.Email"></label>
|
<label asp-for="Input.Email"></label>
|
||||||
<input asp-for="Input.Email" class="form-control" />
|
<input asp-for="Input.Email"
|
||||||
<span asp-validation-for="Input.Email" class="text-danger"></span>
|
class="form-control" />
|
||||||
|
<span asp-validation-for="Input.Email"
|
||||||
|
class="text-danger">
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label asp-for="Input.Password"></label>
|
<label asp-for="Input.Password"></label>
|
||||||
<input asp-for="Input.Password" class="form-control" />
|
<input asp-for="Input.Password"
|
||||||
<span asp-validation-for="Input.Password" class="text-danger"></span>
|
class="form-control" />
|
||||||
|
<span asp-validation-for="Input.Password"
|
||||||
|
class="text-danger">
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="checkbox">
|
<div class="checkbox">
|
||||||
@@ -63,14 +73,23 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<button type="submit" class="btn btn-default">Log in</button>
|
<button class="btn btn-primary"
|
||||||
|
type="submit">
|
||||||
|
Log in
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<p>
|
<p>
|
||||||
<a asp-page="./ForgotPassword">Forgot your password?</a>
|
<a asp-page="./ForgotPassword"
|
||||||
|
id="forgot-password">
|
||||||
|
Forgot your password?
|
||||||
|
</a>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<a asp-page="./Register" asp-route-returnUrl="@Model.ReturnUrl">Register as a new user</a>
|
<a asp-page="./Register"
|
||||||
|
asp-route-returnUrl="@Model.ReturnUrl">
|
||||||
|
Register as a new user
|
||||||
|
</a>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
@@ -81,7 +100,7 @@
|
|||||||
<h4>Use another service to log in.</h4>
|
<h4>Use another service to log in.</h4>
|
||||||
<hr />
|
<hr />
|
||||||
@{
|
@{
|
||||||
if ((Model.ExternalLogins?.Count ?? 0) == 0)
|
if((Model.ExternalLogins?.Count ?? 0) == 0)
|
||||||
{
|
{
|
||||||
<div>
|
<div>
|
||||||
<p>
|
<p>
|
||||||
@@ -92,12 +111,21 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<form asp-page="./ExternalLogin" asp-route-returnUrl="@Model.ReturnUrl" method="post" class="form-horizontal">
|
<form id="external-account"
|
||||||
|
asp-page="./ExternalLogin"
|
||||||
|
asp-route-returnUrl="@Model.ReturnUrl"
|
||||||
|
method="post"
|
||||||
|
class="form-horizontal">
|
||||||
<div>
|
<div>
|
||||||
<p>
|
<p>
|
||||||
@foreach (var provider in Model.ExternalLogins)
|
@foreach(AuthenticationScheme provider in Model.ExternalLogins)
|
||||||
{
|
{
|
||||||
<button type="submit" class="btn btn-default" name="provider" value="@provider.Name" title="Log in using your @provider.DisplayName account">@provider.DisplayName</button>
|
<button type="submit"
|
||||||
|
class="btn btn-primary"
|
||||||
|
name="provider"
|
||||||
|
value="@provider.Name"
|
||||||
|
title="Log in using your @provider.DisplayName account">
|
||||||
|
@provider.DisplayName</button>
|
||||||
}
|
}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
// Canary Islands Computer Museum Website
|
// Canary Islands Computer Museum Website
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -35,18 +35,26 @@
|
|||||||
ViewData["Title"] = "Two-factor authentication";
|
ViewData["Title"] = "Two-factor authentication";
|
||||||
}
|
}
|
||||||
|
|
||||||
<h2>@ViewData["Title"]</h2>
|
<h1>@ViewData["Title"]</h1>
|
||||||
<hr />
|
<hr />
|
||||||
<p>Your login is protected with an authenticator app. Enter your authenticator code below.</p>
|
<p>Your login is protected with an authenticator app. Enter your authenticator code below.</p>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
<form method="post" asp-route-returnUrl="@Model.ReturnUrl">
|
<form method="post"
|
||||||
<input asp-for="RememberMe" type="hidden" />
|
asp-route-returnUrl="@Model.ReturnUrl">
|
||||||
<div asp-validation-summary="All" class="text-danger"></div>
|
<input asp-for="RememberMe"
|
||||||
|
type="hidden" />
|
||||||
|
<div asp-validation-summary="All"
|
||||||
|
class="text-danger">
|
||||||
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label asp-for="Input.TwoFactorCode"></label>
|
<label asp-for="Input.TwoFactorCode"></label>
|
||||||
<input asp-for="Input.TwoFactorCode" class="form-control" autocomplete="off" />
|
<input asp-for="Input.TwoFactorCode"
|
||||||
<span asp-validation-for="Input.TwoFactorCode" class="text-danger"></span>
|
class="form-control"
|
||||||
|
autocomplete="off" />
|
||||||
|
<span asp-validation-for="Input.TwoFactorCode"
|
||||||
|
class="text-danger">
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="checkbox">
|
<div class="checkbox">
|
||||||
@@ -57,14 +65,21 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<button type="submit" class="btn btn-default">Log in</button>
|
<button class="btn btn-primary"
|
||||||
|
type="submit">
|
||||||
|
Log in
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<p>
|
<p>
|
||||||
Don't have access to your authenticator device? You can
|
Don't have access to your authenticator device? You can
|
||||||
<a asp-page="./LoginWithRecoveryCode" asp-route-returnUrl="@Model.ReturnUrl">log in with a recovery code</a>.
|
<a id="recovery-code-login"
|
||||||
|
asp-page="./LoginWithRecoveryCode"
|
||||||
|
asp-route-returnUrl="@Model.ReturnUrl">
|
||||||
|
log in with a recovery code
|
||||||
|
</a>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
@section Scripts {
|
@section Scripts {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
// Canary Islands Computer Museum Website
|
// Canary Islands Computer Museum Website
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
@@ -64,7 +64,7 @@ namespace cicm_web.Areas.Identity.Pages.Account
|
|||||||
// Ensure the user has gone through the username & password screen first
|
// Ensure the user has gone through the username & password screen first
|
||||||
IdentityUser user = await _signInManager.GetTwoFactorAuthenticationUserAsync();
|
IdentityUser user = await _signInManager.GetTwoFactorAuthenticationUserAsync();
|
||||||
|
|
||||||
if(user == null) throw new InvalidOperationException($"Unable to load two-factor authentication user.");
|
if(user == null) throw new InvalidOperationException("Unable to load two-factor authentication user.");
|
||||||
|
|
||||||
ReturnUrl = returnUrl;
|
ReturnUrl = returnUrl;
|
||||||
RememberMe = rememberMe;
|
RememberMe = rememberMe;
|
||||||
@@ -79,7 +79,7 @@ namespace cicm_web.Areas.Identity.Pages.Account
|
|||||||
returnUrl = returnUrl ?? Url.Content("~/");
|
returnUrl = returnUrl ?? Url.Content("~/");
|
||||||
|
|
||||||
IdentityUser user = await _signInManager.GetTwoFactorAuthenticationUserAsync();
|
IdentityUser user = await _signInManager.GetTwoFactorAuthenticationUserAsync();
|
||||||
if(user == null) throw new InvalidOperationException($"Unable to load two-factor authentication user.");
|
if(user == null) throw new InvalidOperationException("Unable to load two-factor authentication user.");
|
||||||
|
|
||||||
string authenticatorCode = Input.TwoFactorCode.Replace(" ", string.Empty).Replace("-", string.Empty);
|
string authenticatorCode = Input.TwoFactorCode.Replace(" ", string.Empty).Replace("-", string.Empty);
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
ViewData["Title"] = "Recovery code verification";
|
ViewData["Title"] = "Recovery code verification";
|
||||||
}
|
}
|
||||||
|
|
||||||
<h2>@ViewData["Title"]</h2>
|
<h1>@ViewData["Title"]</h1>
|
||||||
<hr />
|
<hr />
|
||||||
<p>
|
<p>
|
||||||
You have requested to log in with a recovery code. This login will not be remembered until you provide
|
You have requested to log in with a recovery code. This login will not be remembered until you provide
|
||||||
@@ -44,17 +44,26 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
<form method="post">
|
<form method="post">
|
||||||
<div asp-validation-summary="All" class="text-danger"></div>
|
<div asp-validation-summary="All"
|
||||||
|
class="text-danger">
|
||||||
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label asp-for="Input.RecoveryCode"></label>
|
<label asp-for="Input.RecoveryCode"></label>
|
||||||
<input asp-for="Input.RecoveryCode" class="form-control" autocomplete="off" />
|
<input asp-for="Input.RecoveryCode"
|
||||||
<span asp-validation-for="Input.RecoveryCode" class="text-danger"></span>
|
class="form-control"
|
||||||
|
autocomplete="off" />
|
||||||
|
<span asp-validation-for="Input.RecoveryCode"
|
||||||
|
class="text-danger">
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="btn btn-default">Log in</button>
|
<button class="btn btn-primary"
|
||||||
|
type="submit">
|
||||||
|
Log in
|
||||||
|
</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@section Scripts {
|
@section Scripts {
|
||||||
<partial name="_ValidationScriptsPartial" />
|
<partial name="_ValidationScriptsPartial" />
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
// Canary Islands Computer Museum Website
|
// Canary Islands Computer Museum Website
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
@@ -62,7 +62,7 @@ namespace cicm_web.Areas.Identity.Pages.Account
|
|||||||
{
|
{
|
||||||
// Ensure the user has gone through the username & password screen first
|
// Ensure the user has gone through the username & password screen first
|
||||||
IdentityUser user = await _signInManager.GetTwoFactorAuthenticationUserAsync();
|
IdentityUser user = await _signInManager.GetTwoFactorAuthenticationUserAsync();
|
||||||
if(user == null) throw new InvalidOperationException($"Unable to load two-factor authentication user.");
|
if(user == null) throw new InvalidOperationException("Unable to load two-factor authentication user.");
|
||||||
|
|
||||||
ReturnUrl = returnUrl;
|
ReturnUrl = returnUrl;
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ namespace cicm_web.Areas.Identity.Pages.Account
|
|||||||
if(!ModelState.IsValid) return Page();
|
if(!ModelState.IsValid) return Page();
|
||||||
|
|
||||||
IdentityUser user = await _signInManager.GetTwoFactorAuthenticationUserAsync();
|
IdentityUser user = await _signInManager.GetTwoFactorAuthenticationUserAsync();
|
||||||
if(user == null) throw new InvalidOperationException($"Unable to load two-factor authentication user.");
|
if(user == null) throw new InvalidOperationException("Unable to load two-factor authentication user.");
|
||||||
|
|
||||||
string recoveryCode = Input.RecoveryCode.Replace(" ", string.Empty);
|
string recoveryCode = Input.RecoveryCode.Replace(" ", string.Empty);
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
// Canary Islands Computer Museum Website
|
// Canary Islands Computer Museum Website
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -33,30 +33,47 @@
|
|||||||
@model ChangePasswordModel
|
@model ChangePasswordModel
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "Change password";
|
ViewData["Title"] = "Change password";
|
||||||
|
ViewData["ActivePage"] = ManageNavPages.ChangePassword;
|
||||||
}
|
}
|
||||||
|
|
||||||
<h4>@ViewData["Title"]</h4>
|
<h4>@ViewData["Title"]</h4>
|
||||||
@Html.Partial("_StatusMessage", Model.StatusMessage)
|
<partial for="StatusMessage"
|
||||||
|
name="_StatusMessage" />
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<form id="change-password-form" method="post">
|
<form id="change-password-form"
|
||||||
<div asp-validation-summary="All" class="text-danger"></div>
|
method="post">
|
||||||
|
<div asp-validation-summary="All"
|
||||||
|
class="text-danger">
|
||||||
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label asp-for="Input.OldPassword"></label>
|
<label asp-for="Input.OldPassword"></label>
|
||||||
<input asp-for="Input.OldPassword" class="form-control" />
|
<input asp-for="Input.OldPassword"
|
||||||
<span asp-validation-for="Input.OldPassword" class="text-danger"></span>
|
class="form-control" />
|
||||||
|
<span asp-validation-for="Input.OldPassword"
|
||||||
|
class="text-danger">
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label asp-for="Input.NewPassword"></label>
|
<label asp-for="Input.NewPassword"></label>
|
||||||
<input asp-for="Input.NewPassword" class="form-control" />
|
<input asp-for="Input.NewPassword"
|
||||||
<span asp-validation-for="Input.NewPassword" class="text-danger"></span>
|
class="form-control" />
|
||||||
|
<span asp-validation-for="Input.NewPassword"
|
||||||
|
class="text-danger">
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label asp-for="Input.ConfirmPassword"></label>
|
<label asp-for="Input.ConfirmPassword"></label>
|
||||||
<input asp-for="Input.ConfirmPassword" class="form-control" />
|
<input asp-for="Input.ConfirmPassword"
|
||||||
<span asp-validation-for="Input.ConfirmPassword" class="text-danger"></span>
|
class="form-control" />
|
||||||
|
<span asp-validation-for="Input.ConfirmPassword"
|
||||||
|
class="text-danger">
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="btn btn-default">Update password</button>
|
<button class="btn btn-primary"
|
||||||
|
type="submit">
|
||||||
|
Update password
|
||||||
|
</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
// Canary Islands Computer Museum Website
|
// Canary Islands Computer Museum Website
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -33,12 +33,13 @@
|
|||||||
@model DeletePersonalDataModel
|
@model DeletePersonalDataModel
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "Delete Personal Data";
|
ViewData["Title"] = "Delete Personal Data";
|
||||||
ViewData["ActivePage"] = ManageNavPages.DeletePersonalData;
|
ViewData["ActivePage"] = ManageNavPages.PersonalData;
|
||||||
}
|
}
|
||||||
|
|
||||||
<h4>@ViewData["Title"]</h4>
|
<h4>@ViewData["Title"]</h4>
|
||||||
|
|
||||||
<div class="alert alert-warning" role="alert">
|
<div class="alert alert-warning"
|
||||||
|
role="alert">
|
||||||
<p>
|
<p>
|
||||||
<span class="glyphicon glyphicon-warning-sign"></span>
|
<span class="glyphicon glyphicon-warning-sign"></span>
|
||||||
<strong>Deleting this data will permanently remove your account, and this cannot be recovered.</strong>
|
<strong>Deleting this data will permanently remove your account, and this cannot be recovered.</strong>
|
||||||
@@ -46,20 +47,30 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<form id="delete-user" method="post" class="form-group">
|
<form class="form-group"
|
||||||
<div asp-validation-summary="All" class="text-danger"></div>
|
id="delete-user"
|
||||||
@if (Model.RequirePassword)
|
method="post">
|
||||||
{
|
<div asp-validation-summary="All"
|
||||||
<div class="form-group">
|
class="text-danger">
|
||||||
<label asp-for="Input.Password"></label>
|
|
||||||
<input asp-for="Input.Password" class="form-control" />
|
|
||||||
<span asp-validation-for="Input.Password" class="text-danger"></span>
|
|
||||||
</div>
|
</div>
|
||||||
|
@if(Model.RequirePassword)
|
||||||
|
{
|
||||||
|
<div class="form-group">
|
||||||
|
<label asp-for="Input.Password"></label>
|
||||||
|
<input asp-for="Input.Password"
|
||||||
|
class="form-control" />
|
||||||
|
<span asp-validation-for="Input.Password"
|
||||||
|
class="text-danger">
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
<button class="btn btn-danger" type="submit">Delete data and close my account</button>
|
<button class="btn btn-danger"
|
||||||
|
type="submit">
|
||||||
|
Delete data and close my account
|
||||||
|
</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@section Scripts {
|
@section Scripts {
|
||||||
<partial name="_ValidationScriptsPartial" />
|
<partial name="_ValidationScriptsPartial" />
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
// Canary Islands Computer Museum Website
|
// Canary Islands Computer Museum Website
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -36,10 +36,12 @@
|
|||||||
ViewData["ActivePage"] = ManageNavPages.TwoFactorAuthentication;
|
ViewData["ActivePage"] = ManageNavPages.TwoFactorAuthentication;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Html.Partial("_StatusMessage", Model.StatusMessage)
|
<partial for="StatusMessage"
|
||||||
<h2>@ViewData["Title"]</h2>
|
name="_StatusMessage" />
|
||||||
|
<h1>@ViewData["Title"]</h1>
|
||||||
|
|
||||||
<div class="alert alert-warning" role="alert">
|
<div class="alert alert-warning"
|
||||||
|
role="alert">
|
||||||
<p>
|
<p>
|
||||||
<span class="glyphicon glyphicon-warning-sign"></span>
|
<span class="glyphicon glyphicon-warning-sign"></span>
|
||||||
<strong>This action only disables 2FA.</strong>
|
<strong>This action only disables 2FA.</strong>
|
||||||
@@ -51,7 +53,11 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<form method="post" class="form-group">
|
<form class="form-group"
|
||||||
<button class="btn btn-danger" type="submit">Disable 2FA</button>
|
method="post">
|
||||||
|
<button class="btn btn-danger"
|
||||||
|
type="submit">
|
||||||
|
Disable 2FA
|
||||||
|
</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
// Canary Islands Computer Museum Website
|
// Canary Islands Computer Museum Website
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
@model DownloadPersonalDataModel
|
@model DownloadPersonalDataModel
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "Download Your Data";
|
ViewData["Title"] = "Download Your Data";
|
||||||
ViewData["ActivePage"] = ManageNavPages.DownloadPersonalData;
|
ViewData["ActivePage"] = ManageNavPages.PersonalData;
|
||||||
}
|
}
|
||||||
|
|
||||||
<h4>@ViewData["Title"]</h4>
|
<h4>@ViewData["Title"]</h4>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
// Canary Islands Computer Museum Website
|
// Canary Islands Computer Museum Website
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -36,7 +36,8 @@
|
|||||||
ViewData["ActivePage"] = ManageNavPages.TwoFactorAuthentication;
|
ViewData["ActivePage"] = ManageNavPages.TwoFactorAuthentication;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Html.Partial("_StatusMessage", Model.StatusMessage)
|
<partial for="StatusMessage"
|
||||||
|
name="_StatusMessage" />
|
||||||
<h4>@ViewData["Title"]</h4>
|
<h4>@ViewData["Title"]</h4>
|
||||||
<div>
|
<div>
|
||||||
<p>To use an authenticator app go through the following steps:</p>
|
<p>To use an authenticator app go through the following steps:</p>
|
||||||
@@ -56,7 +57,9 @@
|
|||||||
<p>Scan the QR Code or enter this key <kbd>@Model.SharedKey</kbd> into your two factor authenticator app. Spaces and casing do not matter.</p>
|
<p>Scan the QR Code or enter this key <kbd>@Model.SharedKey</kbd> into your two factor authenticator app. Spaces and casing do not matter.</p>
|
||||||
<div class="alert alert-info">To enable QR code generation please read our <a href="https://go.microsoft.com/fwlink/?Linkid=852423">documentation</a>.</div>
|
<div class="alert alert-info">To enable QR code generation please read our <a href="https://go.microsoft.com/fwlink/?Linkid=852423">documentation</a>.</div>
|
||||||
<div id="qrCode"></div>
|
<div id="qrCode"></div>
|
||||||
<div id="qrCodeData" data-url="@Html.Raw(Model.AuthenticatorUri)"></div>
|
<div id="qrCodeData"
|
||||||
|
data-url="@Html.Raw(Model.AuthenticatorUri)">
|
||||||
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<p>
|
<p>
|
||||||
@@ -65,14 +68,27 @@
|
|||||||
</p>
|
</p>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<form method="post">
|
<form id="send-code"
|
||||||
|
method="post">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label asp-for="Input.Code" class="control-label">Verification Code</label>
|
<label asp-for="Input.Code"
|
||||||
<input asp-for="Input.Code" class="form-control" autocomplete="off" />
|
class="control-label">
|
||||||
<span asp-validation-for="Input.Code" class="text-danger"></span>
|
Verification Code
|
||||||
|
</label>
|
||||||
|
<input asp-for="Input.Code"
|
||||||
|
class="form-control"
|
||||||
|
autocomplete="off" />
|
||||||
|
<span asp-validation-for="Input.Code"
|
||||||
|
class="text-danger">
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<button class="btn btn-primary"
|
||||||
|
type="submit">
|
||||||
|
Verify
|
||||||
|
</button>
|
||||||
|
<div asp-validation-summary="ModelOnly"
|
||||||
|
class="text-danger">
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="btn btn-default">Verify</button>
|
|
||||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
// Canary Islands Computer Museum Website
|
// Canary Islands Computer Museum Website
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
@@ -153,11 +153,9 @@ namespace cicm_web.Areas.Identity.Pages.Account.Manage
|
|||||||
return result.ToString().ToLowerInvariant();
|
return result.ToString().ToLowerInvariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
string GenerateQrCodeUri(string email, string unformattedKey)
|
string GenerateQrCodeUri(string email, string unformattedKey) =>
|
||||||
{
|
string.Format(AuthenticatorUriFormat, _urlEncoder.Encode("cicm_web"), _urlEncoder.Encode(email),
|
||||||
return string.Format(AuthenticatorUriFormat, _urlEncoder.Encode("cicm_web"), _urlEncoder.Encode(email),
|
unformattedKey);
|
||||||
unformattedKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
public class InputModel
|
public class InputModel
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -30,52 +30,74 @@
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
}
|
}
|
||||||
@page
|
@page
|
||||||
|
@using Microsoft.AspNetCore.Authentication
|
||||||
@model ExternalLoginsModel
|
@model ExternalLoginsModel
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "Manage your external logins";
|
ViewData["Title"] = "Manage your external logins";
|
||||||
|
ViewData["ActivePage"] = ManageNavPages.ExternalLogins;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Html.Partial("_StatusMessage", Model.StatusMessage)
|
<partial for="StatusMessage"
|
||||||
@if (Model.CurrentLogins?.Count > 0)
|
name="_StatusMessage" />
|
||||||
|
@if(Model.CurrentLogins?.Count > 0)
|
||||||
{
|
{
|
||||||
<h4>Registered Logins</h4>
|
<h4>Registered Logins</h4>
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<tbody>
|
<tbody>
|
||||||
@foreach (var login in Model.CurrentLogins)
|
@foreach(UserLoginInfo login in Model.CurrentLogins)
|
||||||
{
|
{
|
||||||
<tr>
|
<tr>
|
||||||
<td>@login.LoginProvider</td>
|
<td>@login.ProviderDisplayName</td>
|
||||||
<td>
|
<td>
|
||||||
@if (Model.ShowRemoveButton)
|
@if(Model.ShowRemoveButton)
|
||||||
{
|
{
|
||||||
<form id="remove-login" asp-page-handler="RemoveLogin" method="post">
|
<form asp-page-handler="RemoveLogin"
|
||||||
|
id="remove-login"
|
||||||
|
method="post">
|
||||||
<div>
|
<div>
|
||||||
<input asp-for="@login.LoginProvider" name="LoginProvider" type="hidden" />
|
<input asp-for="@login.LoginProvider"
|
||||||
<input asp-for="@login.ProviderKey" name="ProviderKey" type="hidden" />
|
name="LoginProvider"
|
||||||
<button type="submit" class="btn btn-default" title="Remove this @login.LoginProvider login from your account">Remove</button>
|
type="hidden" />
|
||||||
|
<input asp-for="@login.ProviderKey"
|
||||||
|
name="ProviderKey"
|
||||||
|
type="hidden" />
|
||||||
|
<button type="submit"
|
||||||
|
class="btn btn-primary"
|
||||||
|
title="Remove this @login.ProviderDisplayName login from your account">
|
||||||
|
Remove
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@:
|
@:
|
||||||
}
|
}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
}
|
}
|
||||||
@if (Model.OtherLogins?.Count > 0)
|
@if(Model.OtherLogins?.Count > 0)
|
||||||
{
|
{
|
||||||
<h4>Add another service to log in.</h4>
|
<h4>Add another service to log in.</h4>
|
||||||
<hr />
|
<hr />
|
||||||
<form id="link-login-form" asp-page-handler="LinkLogin" method="post" class="form-horizontal">
|
<form asp-page-handler="LinkLogin"
|
||||||
|
class="form-horizontal"
|
||||||
|
id="link-login-form"
|
||||||
|
method="post">
|
||||||
<div id="socialLoginList">
|
<div id="socialLoginList">
|
||||||
<p>
|
<p>
|
||||||
@foreach (var provider in Model.OtherLogins)
|
@foreach(AuthenticationScheme provider in Model.OtherLogins)
|
||||||
{
|
{
|
||||||
<button id="link-login-button" type="submit" class="btn btn-default" name="provider" value="@provider.Name" title="Log in using your @provider.DisplayName account">@provider.DisplayName</button>
|
<button id="link-login-button"
|
||||||
|
type="submit"
|
||||||
|
class="btn btn-primary"
|
||||||
|
name="provider"
|
||||||
|
value="@provider.Name"
|
||||||
|
title="Log in using your @provider.DisplayName account">
|
||||||
|
@provider.DisplayName</button>
|
||||||
}
|
}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
// Canary Islands Computer Museum Website
|
// Canary Islands Computer Museum Website
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -36,9 +36,11 @@
|
|||||||
ViewData["ActivePage"] = ManageNavPages.TwoFactorAuthentication;
|
ViewData["ActivePage"] = ManageNavPages.TwoFactorAuthentication;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Html.Partial("_StatusMessage", Model.StatusMessage)
|
<partial for="StatusMessage"
|
||||||
|
name="_StatusMessage" />
|
||||||
<h4>@ViewData["Title"]</h4>
|
<h4>@ViewData["Title"]</h4>
|
||||||
<div class="alert alert-warning" role="alert">
|
<div class="alert alert-warning"
|
||||||
|
role="alert">
|
||||||
<p>
|
<p>
|
||||||
<span class="glyphicon glyphicon-warning-sign"></span>
|
<span class="glyphicon glyphicon-warning-sign"></span>
|
||||||
<strong>Put these codes in a safe place.</strong>
|
<strong>Put these codes in a safe place.</strong>
|
||||||
@@ -52,7 +54,11 @@
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<form method="post" class="form-group">
|
<form class="form-group"
|
||||||
<button class="btn btn-danger" type="submit">Generate Recovery Codes</button>
|
method="post">
|
||||||
|
<button class="btn btn-danger"
|
||||||
|
type="submit">
|
||||||
|
Generate Recovery Codes
|
||||||
|
</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
// Canary Islands Computer Museum Website
|
// Canary Islands Computer Museum Website
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
@@ -63,14 +63,11 @@ namespace cicm_web.Areas.Identity.Pages.Account.Manage
|
|||||||
if(user == null) return NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
|
if(user == null) return NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
|
||||||
|
|
||||||
bool isTwoFactorEnabled = await _userManager.GetTwoFactorEnabledAsync(user);
|
bool isTwoFactorEnabled = await _userManager.GetTwoFactorEnabledAsync(user);
|
||||||
if(!isTwoFactorEnabled)
|
if(isTwoFactorEnabled) return Page();
|
||||||
{
|
|
||||||
string userId = await _userManager.GetUserIdAsync(user);
|
|
||||||
throw new
|
|
||||||
InvalidOperationException($"Cannot generate recovery codes for user with ID '{userId}' because they do not have 2FA enabled.");
|
|
||||||
}
|
|
||||||
|
|
||||||
return Page();
|
string userId = await _userManager.GetUserIdAsync(user);
|
||||||
|
throw new
|
||||||
|
InvalidOperationException($"Cannot generate recovery codes for user with ID '{userId}' because they do not have 2FA enabled.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IActionResult> OnPostAsync()
|
public async Task<IActionResult> OnPostAsync()
|
||||||
|
|||||||
@@ -33,40 +33,66 @@
|
|||||||
@model IndexModel
|
@model IndexModel
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "Profile";
|
ViewData["Title"] = "Profile";
|
||||||
|
ViewData["ActivePage"] = ManageNavPages.Index;
|
||||||
}
|
}
|
||||||
|
|
||||||
<h4>@ViewData["Title"]</h4>
|
<h4>@ViewData["Title"]</h4>
|
||||||
@Html.Partial("_StatusMessage", Model.StatusMessage)
|
<partial for="StatusMessage"
|
||||||
|
name="_StatusMessage" />
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<form id="profile-form" method="post">
|
<form id="profile-form"
|
||||||
<div asp-validation-summary="All" class="text-danger"></div>
|
method="post">
|
||||||
|
<div asp-validation-summary="All"
|
||||||
|
class="text-danger">
|
||||||
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label asp-for="Username"></label>
|
<label asp-for="Username"></label>
|
||||||
<input asp-for="Username" class="form-control" disabled />
|
<input asp-for="Username"
|
||||||
|
class="form-control"
|
||||||
|
disabled />
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label asp-for="Input.Email"></label>
|
<label asp-for="Input.Email"></label>
|
||||||
@if (Model.IsEmailConfirmed)
|
@if(Model.IsEmailConfirmed)
|
||||||
{
|
{
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<input asp-for="Input.Email" class="form-control" />
|
<input asp-for="Input.Email"
|
||||||
<span class="input-group-addon" aria-hidden="true"><span class="glyphicon glyphicon-ok text-success"></span></span>
|
class="form-control" />
|
||||||
|
<span aria-hidden="true"
|
||||||
|
class="input-group-addon">
|
||||||
|
<span class="glyphicon glyphicon-ok text-success"></span>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<input asp-for="Input.Email" class="form-control" />
|
<input asp-for="Input.Email"
|
||||||
<button id="email-verification" type="submit" asp-page-handler="SendVerificationEmail" class="btn btn-link">Send verification email</button>
|
class="form-control" />
|
||||||
|
<button asp-page-handler="SendVerificationEmail"
|
||||||
|
class="btn btn-link"
|
||||||
|
id="email-verification"
|
||||||
|
type="submit">
|
||||||
|
Send verification email
|
||||||
|
</button>
|
||||||
}
|
}
|
||||||
<span asp-validation-for="Input.Email" class="text-danger"></span>
|
<span asp-validation-for="Input.Email"
|
||||||
|
class="text-danger">
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label asp-for="Input.PhoneNumber"></label>
|
<label asp-for="Input.PhoneNumber"></label>
|
||||||
<input asp-for="Input.PhoneNumber" class="form-control" />
|
<input asp-for="Input.PhoneNumber"
|
||||||
<span asp-validation-for="Input.PhoneNumber" class="text-danger"></span>
|
class="form-control" />
|
||||||
|
<span asp-validation-for="Input.PhoneNumber"
|
||||||
|
class="text-danger">
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="btn btn-default">Save</button>
|
<button class="btn btn-primary"
|
||||||
|
id="update-profile-button"
|
||||||
|
type="submit">
|
||||||
|
Save
|
||||||
|
</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
// Canary Islands Computer Museum Website
|
// Canary Islands Computer Museum Website
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
// Canary Islands Computer Museum Website
|
// Canary Islands Computer Museum Website
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
@@ -40,10 +40,6 @@ namespace cicm_web.Areas.Identity.Pages.Account.Manage
|
|||||||
|
|
||||||
public static string ChangePassword => "ChangePassword";
|
public static string ChangePassword => "ChangePassword";
|
||||||
|
|
||||||
public static string DownloadPersonalData => "DownloadPersonalData";
|
|
||||||
|
|
||||||
public static string DeletePersonalData => "DeletePersonalData";
|
|
||||||
|
|
||||||
public static string ExternalLogins => "ExternalLogins";
|
public static string ExternalLogins => "ExternalLogins";
|
||||||
|
|
||||||
public static string PersonalData => "PersonalData";
|
public static string PersonalData => "PersonalData";
|
||||||
@@ -55,12 +51,6 @@ namespace cicm_web.Areas.Identity.Pages.Account.Manage
|
|||||||
public static string ChangePasswordNavClass(ViewContext viewContext) =>
|
public static string ChangePasswordNavClass(ViewContext viewContext) =>
|
||||||
PageNavClass(viewContext, ChangePassword);
|
PageNavClass(viewContext, ChangePassword);
|
||||||
|
|
||||||
public static string DownloadPersonalDataNavClass(ViewContext viewContext) =>
|
|
||||||
PageNavClass(viewContext, DownloadPersonalData);
|
|
||||||
|
|
||||||
public static string DeletePersonalDataNavClass(ViewContext viewContext) =>
|
|
||||||
PageNavClass(viewContext, DeletePersonalData);
|
|
||||||
|
|
||||||
public static string ExternalLoginsNavClass(ViewContext viewContext) =>
|
public static string ExternalLoginsNavClass(ViewContext viewContext) =>
|
||||||
PageNavClass(viewContext, ExternalLogins);
|
PageNavClass(viewContext, ExternalLogins);
|
||||||
|
|
||||||
@@ -69,7 +59,7 @@ namespace cicm_web.Areas.Identity.Pages.Account.Manage
|
|||||||
public static string TwoFactorAuthenticationNavClass(ViewContext viewContext) =>
|
public static string TwoFactorAuthenticationNavClass(ViewContext viewContext) =>
|
||||||
PageNavClass(viewContext, TwoFactorAuthentication);
|
PageNavClass(viewContext, TwoFactorAuthentication);
|
||||||
|
|
||||||
public static string PageNavClass(ViewContext viewContext, string page)
|
static string PageNavClass(ViewContext viewContext, string page)
|
||||||
{
|
{
|
||||||
string activePage = viewContext.ViewData["ActivePage"] as string ??
|
string activePage = viewContext.ViewData["ActivePage"] as string ??
|
||||||
Path.GetFileNameWithoutExtension(viewContext.ActionDescriptor.DisplayName);
|
Path.GetFileNameWithoutExtension(viewContext.ActionDescriptor.DisplayName);
|
||||||
|
|||||||
@@ -44,11 +44,21 @@
|
|||||||
<p>
|
<p>
|
||||||
<strong>Deleting this data will permanently remove your account, and this cannot be recovered.</strong>
|
<strong>Deleting this data will permanently remove your account, and this cannot be recovered.</strong>
|
||||||
</p>
|
</p>
|
||||||
<form asp-page="DownloadPersonalData" method="post" class="form-group">
|
<form asp-page="DownloadPersonalData"
|
||||||
<button class="btn btn-default" type="submit">Download</button>
|
class="form-group"
|
||||||
|
id="download-data"
|
||||||
|
method="post">
|
||||||
|
<button class="btn btn-primary"
|
||||||
|
type="submit">
|
||||||
|
Download
|
||||||
|
</button>
|
||||||
</form>
|
</form>
|
||||||
<p>
|
<p>
|
||||||
<a asp-page="DeletePersonalData" class="btn btn-default">Delete</a>
|
<a asp-page="DeletePersonalData"
|
||||||
|
class="btn btn-primary"
|
||||||
|
id="delete">
|
||||||
|
Delete
|
||||||
|
</a>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
// Canary Islands Computer Museum Website
|
// Canary Islands Computer Museum Website
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -36,9 +36,11 @@
|
|||||||
ViewData["ActivePage"] = ManageNavPages.TwoFactorAuthentication;
|
ViewData["ActivePage"] = ManageNavPages.TwoFactorAuthentication;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Html.Partial("_StatusMessage", Model.StatusMessage)
|
<partial for="StatusMessage"
|
||||||
|
name="_StatusMessage" />
|
||||||
<h4>@ViewData["Title"]</h4>
|
<h4>@ViewData["Title"]</h4>
|
||||||
<div class="alert alert-warning" role="alert">
|
<div class="alert alert-warning"
|
||||||
|
role="alert">
|
||||||
<p>
|
<p>
|
||||||
<span class="glyphicon glyphicon-warning-sign"></span>
|
<span class="glyphicon glyphicon-warning-sign"></span>
|
||||||
<strong>If you reset your authenticator key your authenticator app will not work until you reconfigure it.</strong>
|
<strong>If you reset your authenticator key your authenticator app will not work until you reconfigure it.</strong>
|
||||||
@@ -49,7 +51,13 @@
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<form id="reset-authenticator-form" method="post" class="form-group">
|
<form class="form-group"
|
||||||
<button id="reset-authenticator-button" class="btn btn-danger" type="submit">Reset authenticator key</button>
|
id="reset-authenticator-form"
|
||||||
|
method="post">
|
||||||
|
<button class="btn btn-danger"
|
||||||
|
id="reset-authenticator-button"
|
||||||
|
type="submit">
|
||||||
|
Reset authenticator key
|
||||||
|
</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
// Canary Islands Computer Museum Website
|
// Canary Islands Computer Museum Website
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
@@ -38,9 +38,9 @@ namespace cicm_web.Areas.Identity.Pages.Account.Manage
|
|||||||
{
|
{
|
||||||
public class ResetAuthenticatorModel : PageModel
|
public class ResetAuthenticatorModel : PageModel
|
||||||
{
|
{
|
||||||
readonly SignInManager<IdentityUser> _signInManager;
|
readonly SignInManager<IdentityUser> _signInManager;
|
||||||
ILogger<ResetAuthenticatorModel> _logger;
|
readonly ILogger<ResetAuthenticatorModel> _logger;
|
||||||
UserManager<IdentityUser> _userManager;
|
readonly UserManager<IdentityUser> _userManager;
|
||||||
|
|
||||||
public ResetAuthenticatorModel(UserManager<IdentityUser> userManager,
|
public ResetAuthenticatorModel(UserManager<IdentityUser> userManager,
|
||||||
SignInManager<IdentityUser> signInManager,
|
SignInManager<IdentityUser> signInManager,
|
||||||
|
|||||||
@@ -37,26 +37,39 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
<h4>Set your password</h4>
|
<h4>Set your password</h4>
|
||||||
@Html.Partial("_StatusMessage", Model.StatusMessage)
|
<partial for="StatusMessage"
|
||||||
|
name="_StatusMessage" />
|
||||||
<p class="text-info">
|
<p class="text-info">
|
||||||
You do not have a local username/password for this site. Add a local
|
You do not have a local username/password for this site. Add a local
|
||||||
account so you can log in without an external login.
|
account so you can log in without an external login.
|
||||||
</p>
|
</p>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<form id="set-password-form" method="post">
|
<form id="set-password-form"
|
||||||
<div asp-validation-summary="All" class="text-danger"></div>
|
method="post">
|
||||||
|
<div asp-validation-summary="All"
|
||||||
|
class="text-danger">
|
||||||
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label asp-for="Input.NewPassword"></label>
|
<label asp-for="Input.NewPassword"></label>
|
||||||
<input asp-for="Input.NewPassword" class="form-control" />
|
<input asp-for="Input.NewPassword"
|
||||||
<span asp-validation-for="Input.NewPassword" class="text-danger"></span>
|
class="form-control" />
|
||||||
|
<span asp-validation-for="Input.NewPassword"
|
||||||
|
class="text-danger">
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label asp-for="Input.ConfirmPassword"></label>
|
<label asp-for="Input.ConfirmPassword"></label>
|
||||||
<input asp-for="Input.ConfirmPassword" class="form-control" />
|
<input asp-for="Input.ConfirmPassword"
|
||||||
<span asp-validation-for="Input.ConfirmPassword" class="text-danger"></span>
|
class="form-control" />
|
||||||
|
<span asp-validation-for="Input.ConfirmPassword"
|
||||||
|
class="text-danger">
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="btn btn-default">Set password</button>
|
<button class="btn btn-primary"
|
||||||
|
type="submit">
|
||||||
|
Set password
|
||||||
|
</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
// Canary Islands Computer Museum Website
|
// Canary Islands Computer Museum Website
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -33,27 +33,29 @@
|
|||||||
@model TwoFactorAuthenticationModel
|
@model TwoFactorAuthenticationModel
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "Two-factor authentication (2FA)";
|
ViewData["Title"] = "Two-factor authentication (2FA)";
|
||||||
|
ViewData["ActivePage"] = ManageNavPages.TwoFactorAuthentication;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Html.Partial("_StatusMessage", Model.StatusMessage)
|
<partial for="StatusMessage"
|
||||||
|
name="_StatusMessage" />
|
||||||
<h4>@ViewData["Title"]</h4>
|
<h4>@ViewData["Title"]</h4>
|
||||||
@if (Model.Is2faEnabled)
|
@if(Model.Is2faEnabled)
|
||||||
{
|
{
|
||||||
if (Model.RecoveryCodesLeft == 0)
|
if(Model.RecoveryCodesLeft == 0)
|
||||||
{
|
{
|
||||||
<div class="alert alert-danger">
|
<div class="alert alert-danger">
|
||||||
<strong>You have no recovery codes left.</strong>
|
<strong>You have no recovery codes left.</strong>
|
||||||
<p>You must <a asp-page="./GenerateRecoveryCodes">generate a new set of recovery codes</a> before you can log in with a recovery code.</p>
|
<p>You must <a asp-page="./GenerateRecoveryCodes">generate a new set of recovery codes</a> before you can log in with a recovery code.</p>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
else if (Model.RecoveryCodesLeft == 1)
|
else if(Model.RecoveryCodesLeft == 1)
|
||||||
{
|
{
|
||||||
<div class="alert alert-danger">
|
<div class="alert alert-danger">
|
||||||
<strong>You have 1 recovery code left.</strong>
|
<strong>You have 1 recovery code left.</strong>
|
||||||
<p>You can <a asp-page="./GenerateRecoveryCodes">generate a new set of recovery codes</a>.</p>
|
<p>You can <a asp-page="./GenerateRecoveryCodes">generate a new set of recovery codes</a>.</p>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
else if (Model.RecoveryCodesLeft <= 3)
|
else if(Model.RecoveryCodesLeft <= 3)
|
||||||
{
|
{
|
||||||
<div class="alert alert-warning">
|
<div class="alert alert-warning">
|
||||||
<strong>You have @Model.RecoveryCodesLeft recovery codes left.</strong>
|
<strong>You have @Model.RecoveryCodesLeft recovery codes left.</strong>
|
||||||
@@ -61,25 +63,47 @@
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Model.IsMachineRemembered)
|
if(Model.IsMachineRemembered)
|
||||||
{
|
{
|
||||||
<form method="post" style="display: inline-block">
|
<form method="post"
|
||||||
<button type="submit" class="btn btn-default">Forget this browser</button>
|
style="display: inline-block">
|
||||||
|
<button class="btn btn-primary"
|
||||||
|
type="submit">
|
||||||
|
Forget this browser
|
||||||
|
</button>
|
||||||
</form>
|
</form>
|
||||||
}
|
}
|
||||||
<a asp-page="./Disable2fa" class="btn btn-default">Disable 2FA</a>
|
<a asp-page="./Disable2fa"
|
||||||
<a asp-page="./GenerateRecoveryCodes" class="btn btn-default">Reset recovery codes</a>
|
class="btn btn-primary">
|
||||||
|
Disable 2FA
|
||||||
|
</a>
|
||||||
|
<a asp-page="./GenerateRecoveryCodes"
|
||||||
|
class="btn btn-primary">
|
||||||
|
Reset recovery codes
|
||||||
|
</a>
|
||||||
}
|
}
|
||||||
|
|
||||||
<h5>Authenticator app</h5>
|
<h5>Authenticator app</h5>
|
||||||
@if (!Model.HasAuthenticator)
|
@if(!Model.HasAuthenticator)
|
||||||
{
|
{
|
||||||
<a id="enable-authenticator" asp-page="./EnableAuthenticator" class="btn btn-default">Add authenticator app</a>
|
<a asp-page="./EnableAuthenticator"
|
||||||
|
class="btn btn-primary"
|
||||||
|
id="enable-authenticator">
|
||||||
|
Add authenticator app
|
||||||
|
</a>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<a id="enable-authenticator" asp-page="./EnableAuthenticator" class="btn btn-default">Setup authenticator app</a>
|
<a asp-page="./EnableAuthenticator"
|
||||||
<a id="reset-authenticator" asp-page="./ResetAuthenticator" class="btn btn-default">Reset authenticator app</a>
|
class="btn btn-primary"
|
||||||
|
id="enable-authenticator">
|
||||||
|
Setup authenticator app
|
||||||
|
</a>
|
||||||
|
<a asp-page="./ResetAuthenticator"
|
||||||
|
class="btn btn-primary"
|
||||||
|
id="reset-authenticator">
|
||||||
|
Reset authenticator app
|
||||||
|
</a>
|
||||||
}
|
}
|
||||||
|
|
||||||
@section Scripts {
|
@section Scripts {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
// Canary Islands Computer Museum Website
|
// Canary Islands Computer Museum Website
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -30,10 +30,10 @@
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
}
|
}
|
||||||
@{
|
@{
|
||||||
Layout = "/Areas/Identity/Pages/_Layout.cshtml";
|
Layout = "/Views/Shared/_Layout.cshtml";
|
||||||
}
|
}
|
||||||
|
|
||||||
<h2>Manage your account</h2>
|
<h1>Manage your account</h1>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<h4>Change your account settings</h4>
|
<h4>Change your account settings</h4>
|
||||||
@@ -49,5 +49,5 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
@section Scripts {
|
@section Scripts {
|
||||||
@RenderSection("Scripts", required: false)
|
@RenderSection("Scripts", false)
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
@{
|
@{
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
// Canary Islands Computer Museum Website
|
// Canary Islands Computer Museum Website
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -31,15 +31,46 @@
|
|||||||
}
|
}
|
||||||
@inject SignInManager<IdentityUser> SignInManager
|
@inject SignInManager<IdentityUser> SignInManager
|
||||||
@{
|
@{
|
||||||
var hasExternalLogins = (await SignInManager.GetExternalAuthenticationSchemesAsync()).Any();
|
bool hasExternalLogins = (await SignInManager.GetExternalAuthenticationSchemesAsync()).Any();
|
||||||
}
|
}
|
||||||
<ul class="nav nav-pills nav-stacked">
|
<ul class="flex-column nav nav-pills">
|
||||||
<li class="@ManageNavPages.IndexNavClass(ViewContext)"><a asp-page="./Index">Profile</a></li>
|
<li class="nav-item">
|
||||||
<li class="@ManageNavPages.ChangePasswordNavClass(ViewContext)"><a id="change-password" asp-page="./ChangePassword">Password</a></li>
|
<a class="nav-link @ManageNavPages.IndexNavClass(ViewContext)"
|
||||||
@if (hasExternalLogins)
|
id="profile"
|
||||||
|
asp-page="./Index">
|
||||||
|
Profile
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link @ManageNavPages.ChangePasswordNavClass(ViewContext)"
|
||||||
|
id="change-password"
|
||||||
|
asp-page="./ChangePassword">
|
||||||
|
Password
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
@if(hasExternalLogins)
|
||||||
{
|
{
|
||||||
<li class="@ManageNavPages.ExternalLoginsNavClass(ViewContext)"><a id="external-login" asp-page="./ExternalLogins">External logins</a></li>
|
<li class="nav-item"
|
||||||
|
id="external-logins">
|
||||||
|
<a id="external-login"
|
||||||
|
class="nav-link @ManageNavPages.ExternalLoginsNavClass(ViewContext)"
|
||||||
|
asp-page="./ExternalLogins">
|
||||||
|
External logins
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
}
|
}
|
||||||
<li class="@ManageNavPages.TwoFactorAuthenticationNavClass(ViewContext)"><a asp-page="./TwoFactorAuthentication">Two-factor authentication</a></li>
|
<li class="nav-item">
|
||||||
<li class="@ManageNavPages.PersonalDataNavClass(ViewContext)"><a asp-page="./PersonalData">Personal data</a></li>
|
<a class="nav-link @ManageNavPages.TwoFactorAuthenticationNavClass(ViewContext)"
|
||||||
|
id="two-factor"
|
||||||
|
asp-page="./TwoFactorAuthentication">
|
||||||
|
Two-factor authentication
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link @ManageNavPages.PersonalDataNavClass(ViewContext)"
|
||||||
|
id="personal-data"
|
||||||
|
asp-page="./PersonalData">
|
||||||
|
Personal data
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
@@ -31,11 +31,17 @@
|
|||||||
}
|
}
|
||||||
@model string
|
@model string
|
||||||
|
|
||||||
@if (!String.IsNullOrEmpty(Model))
|
@if(!string.IsNullOrEmpty(Model))
|
||||||
{
|
{
|
||||||
var statusMessageClass = Model.StartsWith("Error") ? "danger" : "success";
|
string statusMessageClass = Model.StartsWith("Error") ? "danger" : "success";
|
||||||
<div class="alert alert-@statusMessageClass alert-dismissible" role="alert">
|
<div class="alert alert-@statusMessageClass alert-dismissible"
|
||||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
|
role="alert">
|
||||||
|
<button aria-label="Close"
|
||||||
|
class="close"
|
||||||
|
data-dismiss="alert"
|
||||||
|
type="button">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
@Model
|
@Model
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
@{
|
@{
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
// Canary Islands Computer Museum Website
|
// Canary Islands Computer Museum Website
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -35,30 +35,45 @@
|
|||||||
ViewData["Title"] = "Register";
|
ViewData["Title"] = "Register";
|
||||||
}
|
}
|
||||||
|
|
||||||
<h2>@ViewData["Title"]</h2>
|
<h1>@ViewData["Title"]</h1>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
<form asp-route-returnUrl="@Model.ReturnUrl" method="post">
|
<form asp-route-returnUrl="@Model.ReturnUrl"
|
||||||
|
method="post">
|
||||||
<h4>Create a new account.</h4>
|
<h4>Create a new account.</h4>
|
||||||
<hr />
|
<hr />
|
||||||
<div asp-validation-summary="All" class="text-danger"></div>
|
<div asp-validation-summary="All"
|
||||||
|
class="text-danger">
|
||||||
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label asp-for="Input.Email"></label>
|
<label asp-for="Input.Email"></label>
|
||||||
<input asp-for="Input.Email" class="form-control" />
|
<input asp-for="Input.Email"
|
||||||
<span asp-validation-for="Input.Email" class="text-danger"></span>
|
class="form-control" />
|
||||||
|
<span asp-validation-for="Input.Email"
|
||||||
|
class="text-danger">
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label asp-for="Input.Password"></label>
|
<label asp-for="Input.Password"></label>
|
||||||
<input asp-for="Input.Password" class="form-control" />
|
<input asp-for="Input.Password"
|
||||||
<span asp-validation-for="Input.Password" class="text-danger"></span>
|
class="form-control" />
|
||||||
|
<span asp-validation-for="Input.Password"
|
||||||
|
class="text-danger">
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label asp-for="Input.ConfirmPassword"></label>
|
<label asp-for="Input.ConfirmPassword"></label>
|
||||||
<input asp-for="Input.ConfirmPassword" class="form-control" />
|
<input asp-for="Input.ConfirmPassword"
|
||||||
<span asp-validation-for="Input.ConfirmPassword" class="text-danger"></span>
|
class="form-control" />
|
||||||
|
<span asp-validation-for="Input.ConfirmPassword"
|
||||||
|
class="text-danger">
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="btn btn-default">Register</button>
|
<button class="btn btn-primary"
|
||||||
|
type="submit">
|
||||||
|
Register
|
||||||
|
</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
// Canary Islands Computer Museum Website
|
// Canary Islands Computer Museum Website
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -35,30 +35,45 @@
|
|||||||
ViewData["Title"] = "Reset password";
|
ViewData["Title"] = "Reset password";
|
||||||
}
|
}
|
||||||
|
|
||||||
<h2>@ViewData["Title"]</h2>
|
<h1>@ViewData["Title"]</h1>
|
||||||
<h4>Reset your password.</h4>
|
<h4>Reset your password.</h4>
|
||||||
<hr />
|
<hr />
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
<form method="post">
|
<form method="post">
|
||||||
<div asp-validation-summary="All" class="text-danger"></div>
|
<div asp-validation-summary="All"
|
||||||
<input asp-for="Input.Code" type="hidden" />
|
class="text-danger">
|
||||||
|
</div>
|
||||||
|
<input asp-for="Input.Code"
|
||||||
|
type="hidden" />
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label asp-for="Input.Email"></label>
|
<label asp-for="Input.Email"></label>
|
||||||
<input asp-for="Input.Email" class="form-control" />
|
<input asp-for="Input.Email"
|
||||||
<span asp-validation-for="Input.Email" class="text-danger"></span>
|
class="form-control" />
|
||||||
|
<span asp-validation-for="Input.Email"
|
||||||
|
class="text-danger">
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label asp-for="Input.Password"></label>
|
<label asp-for="Input.Password"></label>
|
||||||
<input asp-for="Input.Password" class="form-control" />
|
<input asp-for="Input.Password"
|
||||||
<span asp-validation-for="Input.Password" class="text-danger"></span>
|
class="form-control" />
|
||||||
|
<span asp-validation-for="Input.Password"
|
||||||
|
class="text-danger">
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label asp-for="Input.ConfirmPassword"></label>
|
<label asp-for="Input.ConfirmPassword"></label>
|
||||||
<input asp-for="Input.ConfirmPassword" class="form-control" />
|
<input asp-for="Input.ConfirmPassword"
|
||||||
<span asp-validation-for="Input.ConfirmPassword" class="text-danger"></span>
|
class="form-control" />
|
||||||
|
<span asp-validation-for="Input.ConfirmPassword"
|
||||||
|
class="text-danger">
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="btn btn-default">Reset</button>
|
<button class="btn btn-primary"
|
||||||
|
type="submit">
|
||||||
|
Reset
|
||||||
|
</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
// Canary Islands Computer Museum Website
|
// Canary Islands Computer Museum Website
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Filename : ResetPassword.cshtml.cs
|
// Filename : ResetPasswordConfirmation.cshtml.cs
|
||||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||||
//
|
//
|
||||||
// --[ Description ] ----------------------------------------------------------
|
// --[ Description ] ----------------------------------------------------------
|
||||||
@@ -63,7 +63,9 @@ namespace cicm_web.Areas.Identity.Pages.Account
|
|||||||
if(!ModelState.IsValid) return Page();
|
if(!ModelState.IsValid) return Page();
|
||||||
|
|
||||||
IdentityUser user = await _userManager.FindByEmailAsync(Input.Email);
|
IdentityUser user = await _userManager.FindByEmailAsync(Input.Email);
|
||||||
if(user == null) return RedirectToPage("./ResetPasswordConfirmation");
|
if(user == null)
|
||||||
|
// Don't reveal that the user does not exist
|
||||||
|
return RedirectToPage("./ResetPasswordConfirmation");
|
||||||
|
|
||||||
IdentityResult result = await _userManager.ResetPasswordAsync(user, Input.Code, Input.Password);
|
IdentityResult result = await _userManager.ResetPasswordAsync(user, Input.Code, Input.Password);
|
||||||
if(result.Succeeded) return RedirectToPage("./ResetPasswordConfirmation");
|
if(result.Succeeded) return RedirectToPage("./ResetPasswordConfirmation");
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
ViewData["Title"] = "Reset password confirmation";
|
ViewData["Title"] = "Reset password confirmation";
|
||||||
}
|
}
|
||||||
|
|
||||||
<h2>@ViewData["Title"]</h2>
|
<h1>@ViewData["Title"]</h1>
|
||||||
<p>
|
<p>
|
||||||
Your password has been reset. Please <a asp-page="./Login">click here to log in</a>.
|
Your password has been reset. Please <a asp-page="./Login">click here to log in</a>.
|
||||||
</p>
|
</p>
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
// Canary Islands Computer Museum Website
|
// Canary Islands Computer Museum Website
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -1,32 +1 @@
|
|||||||
@{
|
|
||||||
/******************************************************************************
|
|
||||||
// Canary Islands Computer Museum Website
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Filename : _ViewImports.cshtml
|
|
||||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
||||||
//
|
|
||||||
// --[ Description ] ----------------------------------------------------------
|
|
||||||
//
|
|
||||||
// ASP.NET Identify management
|
|
||||||
//
|
|
||||||
// --[ License ] --------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// This program is free software: you can redistribute it and/or modify
|
|
||||||
// it under the terms of the GNU General Public License as
|
|
||||||
// published by the Free Software Foundation, either version 3 of the
|
|
||||||
// License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU General Public License
|
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
//
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// Copyright © 2003-2018 Natalia Portillo
|
|
||||||
*******************************************************************************/
|
|
||||||
}
|
|
||||||
@using cicm_web.Areas.Identity.Pages.Account
|
@using cicm_web.Areas.Identity.Pages.Account
|
||||||
@@ -38,7 +38,7 @@
|
|||||||
<h1 class="text-danger">Error.</h1>
|
<h1 class="text-danger">Error.</h1>
|
||||||
<h2 class="text-danger">An error occurred while processing your request.</h2>
|
<h2 class="text-danger">An error occurred while processing your request.</h2>
|
||||||
|
|
||||||
@if (Model.ShowRequestId)
|
@if(Model.ShowRequestId)
|
||||||
{
|
{
|
||||||
<p>
|
<p>
|
||||||
<strong>Request ID:</strong> <code>@Model.RequestId</code>
|
<strong>Request ID:</strong> <code>@Model.RequestId</code>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
// Canary Islands Computer Museum Website
|
// Canary Islands Computer Museum Website
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
@@ -36,13 +36,13 @@ using Microsoft.AspNetCore.Mvc.RazorPages;
|
|||||||
namespace cicm_web.Areas.Identity.Pages
|
namespace cicm_web.Areas.Identity.Pages
|
||||||
{
|
{
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
|
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||||
public class ErrorModel : PageModel
|
public class ErrorModel : PageModel
|
||||||
{
|
{
|
||||||
public string RequestId { get; set; }
|
public string RequestId { get; set; }
|
||||||
|
|
||||||
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
|
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
|
||||||
|
|
||||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
|
||||||
public void OnGet()
|
public void OnGet()
|
||||||
{
|
{
|
||||||
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
|
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
@{
|
@{
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
// Canary Islands Computer Museum Website
|
// Canary Islands Computer Museum Website
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -30,20 +30,20 @@
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
}
|
}
|
||||||
<environment include="Development">
|
<environment include="Development">
|
||||||
<script src="~/Identity/lib/jquery-validation/dist/jquery.validate.js"></script>
|
<script src="~/lib/jquery-validation/dist/jquery.validate.js"></script>
|
||||||
<script src="~/Identity/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js"></script>
|
<script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js"></script>
|
||||||
</environment>
|
</environment>
|
||||||
<environment exclude="Development">
|
<environment exclude="Development">
|
||||||
<script src="https://ajax.aspnetcdn.com/ajax/jquery.validate/1.17.0/jquery.validate.min.js"
|
<script asp-fallback-src="~/Identity/lib/jquery-validation/dist/jquery.validate.min.js"
|
||||||
asp-fallback-src="~/Identity/lib/jquery-validation/dist/jquery.validate.min.js"
|
|
||||||
asp-fallback-test="window.jQuery && window.jQuery.validator"
|
asp-fallback-test="window.jQuery && window.jQuery.validator"
|
||||||
crossorigin="anonymous"
|
crossorigin="anonymous"
|
||||||
integrity="sha384-rZfj/ogBloos6wzLGpPkkOr/gpkBNLZ6b6yLy4o+ok+t/SAKlL5mvXLr0OXNi1Hp">
|
integrity="sha384-rZfj/ogBloos6wzLGpPkkOr/gpkBNLZ6b6yLy4o+ok+t/SAKlL5mvXLr0OXNi1Hp"
|
||||||
|
src="https://ajax.aspnetcdn.com/ajax/jquery.validate/1.17.0/jquery.validate.min.js">
|
||||||
</script>
|
</script>
|
||||||
<script src="https://ajax.aspnetcdn.com/ajax/jquery.validation.unobtrusive/3.2.9/jquery.validate.unobtrusive.min.js"
|
<script asp-fallback-src="~/Identity/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"
|
||||||
asp-fallback-src="~/Identity/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"
|
|
||||||
asp-fallback-test="window.jQuery && window.jQuery.validator && window.jQuery.validator.unobtrusive"
|
asp-fallback-test="window.jQuery && window.jQuery.validator && window.jQuery.validator.unobtrusive"
|
||||||
crossorigin="anonymous"
|
crossorigin="anonymous"
|
||||||
integrity="sha384-ifv0TYDWxBHzvAk2Z0n8R434FL1Rlv/Av18DXE43N/1rvHyOG4izKst0f2iSLdds">
|
integrity="sha384-ifv0TYDWxBHzvAk2Z0n8R434FL1Rlv/Av18DXE43N/1rvHyOG4izKst0f2iSLdds"
|
||||||
|
src="https://ajax.aspnetcdn.com/ajax/jquery.validation.unobtrusive/3.2.9/jquery.validate.unobtrusive.min.js">
|
||||||
</script>
|
</script>
|
||||||
</environment>
|
</environment>
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
@{
|
@{
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
// Canary Islands Computer Museum Website
|
// Canary Islands Computer Museum Website
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
@{
|
@{
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
// Canary Islands Computer Museum Website
|
// Canary Islands Computer Museum Website
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -29,7 +29,6 @@
|
|||||||
// Copyright © 2003-2018 Natalia Portillo
|
// Copyright © 2003-2018 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
}
|
}
|
||||||
|
|
||||||
@{
|
@{
|
||||||
Layout = "/Views/Shared/_Layout.cshtml";
|
Layout = "/Views/Shared/_Layout.cshtml";
|
||||||
}
|
}
|
||||||
@@ -62,8 +62,6 @@ namespace cicm_web
|
|||||||
services.AddDbContext<cicmContext>(options => options
|
services.AddDbContext<cicmContext>(options => options
|
||||||
.UseLazyLoadingProxies()
|
.UseLazyLoadingProxies()
|
||||||
.UseMySql("server=localhost;port=3306;user=cicm;password=cicmpass;database=cicm"));
|
.UseMySql("server=localhost;port=3306;user=cicm;password=cicmpass;database=cicm"));
|
||||||
services.AddDefaultIdentity<IdentityUser>()
|
|
||||||
.AddEntityFrameworkStores<cicmContext>();
|
|
||||||
services.AddMvc();
|
services.AddMvc();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"Logging": {
|
"Logging": {
|
||||||
"IncludeScopes": false,
|
"IncludeScopes": false,
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||||
<Version>3.0.99.358</Version>
|
<Version>3.0.99.371</Version>
|
||||||
<Company>Canary Islands Computer Museum</Company>
|
<Company>Canary Islands Computer Museum</Company>
|
||||||
<Copyright>Copyright © 2003-2018 Natalia Portillo</Copyright>
|
<Copyright>Copyright © 2003-2018 Natalia Portillo</Copyright>
|
||||||
<Product>Canary Islands Computer Museum Website</Product>
|
<Product>Canary Islands Computer Museum Website</Product>
|
||||||
|
|||||||
Reference in New Issue
Block a user