diff --git a/cicm_web/Areas/Identity/IdentityHostingStartup.cs b/cicm_web/Areas/Identity/IdentityHostingStartup.cs index 16222e02..9911c64e 100644 --- a/cicm_web/Areas/Identity/IdentityHostingStartup.cs +++ b/cicm_web/Areas/Identity/IdentityHostingStartup.cs @@ -1,4 +1,4 @@ -/****************************************************************************** +/****************************************************************************** // Canary Islands Computer Museum Website // ---------------------------------------------------------------------------- // @@ -28,8 +28,12 @@ // Copyright © 2003-2018 Natalia Portillo *******************************************************************************/ +using Cicm.Database.Models; using cicm_web.Areas.Identity; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Identity; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; [assembly: HostingStartup(typeof(IdentityHostingStartup))] @@ -39,7 +43,15 @@ namespace cicm_web.Areas.Identity { public void Configure(IWebHostBuilder builder) { - builder.ConfigureServices((context, services) => { }); + builder.ConfigureServices((context, services) => + { + services.AddDbContext(options => options + .UseLazyLoadingProxies() + .UseMySql("server=localhost;port=3306;user=cicm;password=cicmpass;database=cicm")); + + services.AddDefaultIdentity().AddRoles() + .AddEntityFrameworkStores(); + }); } } } \ No newline at end of file diff --git a/cicm_web/Areas/Identity/Pages/Account/AccessDenied.cshtml b/cicm_web/Areas/Identity/Pages/Account/AccessDenied.cshtml index 236ac9dd..27b60c7b 100644 --- a/cicm_web/Areas/Identity/Pages/Account/AccessDenied.cshtml +++ b/cicm_web/Areas/Identity/Pages/Account/AccessDenied.cshtml @@ -38,4 +38,4 @@

@ViewData["Title"]

You do not have access to this resource.

-
+ \ No newline at end of file diff --git a/cicm_web/Areas/Identity/Pages/Account/AccessDenied.cshtml.cs b/cicm_web/Areas/Identity/Pages/Account/AccessDenied.cshtml.cs index 98d71c57..b54fec02 100644 --- a/cicm_web/Areas/Identity/Pages/Account/AccessDenied.cshtml.cs +++ b/cicm_web/Areas/Identity/Pages/Account/AccessDenied.cshtml.cs @@ -1,4 +1,4 @@ -/****************************************************************************** +/****************************************************************************** // Canary Islands Computer Museum Website // ---------------------------------------------------------------------------- // diff --git a/cicm_web/Areas/Identity/Pages/Account/ConfirmEmail.cshtml b/cicm_web/Areas/Identity/Pages/Account/ConfirmEmail.cshtml index c529d5f3..bd58c3ee 100644 --- a/cicm_web/Areas/Identity/Pages/Account/ConfirmEmail.cshtml +++ b/cicm_web/Areas/Identity/Pages/Account/ConfirmEmail.cshtml @@ -35,9 +35,9 @@ ViewData["Title"] = "Confirm email"; } -

@ViewData["Title"]

+

@ViewData["Title"]

Thank you for confirming your email.

-
+ \ No newline at end of file diff --git a/cicm_web/Areas/Identity/Pages/Account/ConfirmEmail.cshtml.cs b/cicm_web/Areas/Identity/Pages/Account/ConfirmEmail.cshtml.cs index 4a2dedff..f0642021 100644 --- a/cicm_web/Areas/Identity/Pages/Account/ConfirmEmail.cshtml.cs +++ b/cicm_web/Areas/Identity/Pages/Account/ConfirmEmail.cshtml.cs @@ -1,4 +1,4 @@ -/****************************************************************************** +/****************************************************************************** // Canary Islands Computer Museum Website // ---------------------------------------------------------------------------- // diff --git a/cicm_web/Areas/Identity/Pages/Account/ExternalLogin.cshtml b/cicm_web/Areas/Identity/Pages/Account/ExternalLogin.cshtml index 9bdc4f23..03b471c3 100644 --- a/cicm_web/Areas/Identity/Pages/Account/ExternalLogin.cshtml +++ b/cicm_web/Areas/Identity/Pages/Account/ExternalLogin.cshtml @@ -35,7 +35,7 @@ ViewData["Title"] = "Register"; } -

@ViewData["Title"]

+

@ViewData["Title"]

Associate your @Model.LoginProvider account.


@@ -47,19 +47,28 @@
-
-
+ +
+
- - + + +
- +
@section Scripts { -} - +} \ No newline at end of file diff --git a/cicm_web/Areas/Identity/Pages/Account/ExternalLogin.cshtml.cs b/cicm_web/Areas/Identity/Pages/Account/ExternalLogin.cshtml.cs index f9d4ad88..4652f6f1 100644 --- a/cicm_web/Areas/Identity/Pages/Account/ExternalLogin.cshtml.cs +++ b/cicm_web/Areas/Identity/Pages/Account/ExternalLogin.cshtml.cs @@ -1,4 +1,4 @@ -/****************************************************************************** +/****************************************************************************** // Canary Islands Computer Museum Website // ---------------------------------------------------------------------------- // diff --git a/cicm_web/Areas/Identity/Pages/Account/ForgotPassword.cshtml b/cicm_web/Areas/Identity/Pages/Account/ForgotPassword.cshtml index f67cb9ec..121bedf8 100644 --- a/cicm_web/Areas/Identity/Pages/Account/ForgotPassword.cshtml +++ b/cicm_web/Areas/Identity/Pages/Account/ForgotPassword.cshtml @@ -35,23 +35,31 @@ ViewData["Title"] = "Forgot your password?"; } -

@ViewData["Title"]

+

@ViewData["Title"]

Enter your email.


-
+
+
- - + + +
- +
@section Scripts { -} +} \ No newline at end of file diff --git a/cicm_web/Areas/Identity/Pages/Account/ForgotPassword.cshtml.cs b/cicm_web/Areas/Identity/Pages/Account/ForgotPassword.cshtml.cs index e77eae75..593c752a 100644 --- a/cicm_web/Areas/Identity/Pages/Account/ForgotPassword.cshtml.cs +++ b/cicm_web/Areas/Identity/Pages/Account/ForgotPassword.cshtml.cs @@ -1,4 +1,4 @@ -/****************************************************************************** +/****************************************************************************** // Canary Islands Computer Museum Website // ---------------------------------------------------------------------------- // @@ -56,24 +56,22 @@ namespace cicm_web.Areas.Identity.Pages.Account public async Task OnPostAsync() { - if(ModelState.IsValid) - { - 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 clicking here."); + if(!ModelState.IsValid) return Page(); + 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 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 clicking here."); + + return RedirectToPage("./ForgotPasswordConfirmation"); } public class InputModel diff --git a/cicm_web/Areas/Identity/Pages/Account/ForgotPasswordConfirmation.cshtml b/cicm_web/Areas/Identity/Pages/Account/ForgotPasswordConfirmation.cshtml index 3c750220..7287b29e 100644 --- a/cicm_web/Areas/Identity/Pages/Account/ForgotPasswordConfirmation.cshtml +++ b/cicm_web/Areas/Identity/Pages/Account/ForgotPasswordConfirmation.cshtml @@ -35,8 +35,7 @@ ViewData["Title"] = "Forgot password confirmation"; } -

@ViewData["Title"]

+

@ViewData["Title"]

Please check your email to reset your password. -

- +

\ No newline at end of file diff --git a/cicm_web/Areas/Identity/Pages/Account/ForgotPasswordConfirmation.cshtml.cs b/cicm_web/Areas/Identity/Pages/Account/ForgotPasswordConfirmation.cshtml.cs index 297db5e0..b684fdd5 100644 --- a/cicm_web/Areas/Identity/Pages/Account/ForgotPasswordConfirmation.cshtml.cs +++ b/cicm_web/Areas/Identity/Pages/Account/ForgotPasswordConfirmation.cshtml.cs @@ -1,4 +1,4 @@ -/****************************************************************************** +/****************************************************************************** // Canary Islands Computer Museum Website // ---------------------------------------------------------------------------- // diff --git a/cicm_web/Areas/Identity/Pages/Account/Lockout.cshtml b/cicm_web/Areas/Identity/Pages/Account/Lockout.cshtml index cddca71f..c49b50ca 100644 --- a/cicm_web/Areas/Identity/Pages/Account/Lockout.cshtml +++ b/cicm_web/Areas/Identity/Pages/Account/Lockout.cshtml @@ -38,4 +38,4 @@

@ViewData["Title"]

This account has been locked out, please try again later.

-
+ \ No newline at end of file diff --git a/cicm_web/Areas/Identity/Pages/Account/Lockout.cshtml.cs b/cicm_web/Areas/Identity/Pages/Account/Lockout.cshtml.cs index 01710541..74374a3e 100644 --- a/cicm_web/Areas/Identity/Pages/Account/Lockout.cshtml.cs +++ b/cicm_web/Areas/Identity/Pages/Account/Lockout.cshtml.cs @@ -1,4 +1,4 @@ -/****************************************************************************** +/****************************************************************************** // Canary Islands Computer Museum Website // ---------------------------------------------------------------------------- // diff --git a/cicm_web/Areas/Identity/Pages/Account/Login.cshtml b/cicm_web/Areas/Identity/Pages/Account/Login.cshtml index c36425d6..9fa347d6 100644 --- a/cicm_web/Areas/Identity/Pages/Account/Login.cshtml +++ b/cicm_web/Areas/Identity/Pages/Account/Login.cshtml @@ -30,29 +30,39 @@ *******************************************************************************/ } @page +@using Microsoft.AspNetCore.Authentication @model LoginModel @{ ViewData["Title"] = "Log in"; } -

@ViewData["Title"]

+

@ViewData["Title"]

-
+

Use a local account to log in.


-
+
+
- - + + +
- - + + +
@@ -63,14 +73,23 @@
- +
@@ -81,7 +100,7 @@

Use another service to log in.


@{ - if ((Model.ExternalLogins?.Count ?? 0) == 0) + if((Model.ExternalLogins?.Count ?? 0) == 0) {

@@ -92,12 +111,21 @@ } else { -

+

- @foreach (var provider in Model.ExternalLogins) + @foreach(AuthenticationScheme provider in Model.ExternalLogins) { - + }

@@ -110,4 +138,4 @@ @section Scripts { -} +} \ No newline at end of file diff --git a/cicm_web/Areas/Identity/Pages/Account/Login.cshtml.cs b/cicm_web/Areas/Identity/Pages/Account/Login.cshtml.cs index d4d51e8d..318bdcb2 100644 --- a/cicm_web/Areas/Identity/Pages/Account/Login.cshtml.cs +++ b/cicm_web/Areas/Identity/Pages/Account/Login.cshtml.cs @@ -1,4 +1,4 @@ -/****************************************************************************** +/****************************************************************************** // Canary Islands Computer Museum Website // ---------------------------------------------------------------------------- // diff --git a/cicm_web/Areas/Identity/Pages/Account/LoginWith2fa.cshtml b/cicm_web/Areas/Identity/Pages/Account/LoginWith2fa.cshtml index 3354847d..ee3227e5 100644 --- a/cicm_web/Areas/Identity/Pages/Account/LoginWith2fa.cshtml +++ b/cicm_web/Areas/Identity/Pages/Account/LoginWith2fa.cshtml @@ -35,18 +35,26 @@ ViewData["Title"] = "Two-factor authentication"; } -

@ViewData["Title"]

+

@ViewData["Title"]


Your login is protected with an authenticator app. Enter your authenticator code below.

- - -
+ + +
+
- - + + +
@@ -57,14 +65,21 @@
- +

- Don't have access to your authenticator device? You can - log in with a recovery code. + Don't have access to your authenticator device? You can + + log in with a recovery code + .

@section Scripts { diff --git a/cicm_web/Areas/Identity/Pages/Account/LoginWith2fa.cshtml.cs b/cicm_web/Areas/Identity/Pages/Account/LoginWith2fa.cshtml.cs index 70826d31..de69bce0 100644 --- a/cicm_web/Areas/Identity/Pages/Account/LoginWith2fa.cshtml.cs +++ b/cicm_web/Areas/Identity/Pages/Account/LoginWith2fa.cshtml.cs @@ -1,4 +1,4 @@ -/****************************************************************************** +/****************************************************************************** // 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 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; RememberMe = rememberMe; @@ -79,7 +79,7 @@ namespace cicm_web.Areas.Identity.Pages.Account returnUrl = returnUrl ?? Url.Content("~/"); 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); diff --git a/cicm_web/Areas/Identity/Pages/Account/LoginWithRecoveryCode.cshtml b/cicm_web/Areas/Identity/Pages/Account/LoginWithRecoveryCode.cshtml index 2fddefcc..7cd4d3fa 100644 --- a/cicm_web/Areas/Identity/Pages/Account/LoginWithRecoveryCode.cshtml +++ b/cicm_web/Areas/Identity/Pages/Account/LoginWithRecoveryCode.cshtml @@ -35,7 +35,7 @@ ViewData["Title"] = "Recovery code verification"; } -

@ViewData["Title"]

+

@ViewData["Title"]


You have requested to log in with a recovery code. This login will not be remembered until you provide @@ -44,17 +44,26 @@

-
+
+
- - + + +
- +
- - @section Scripts { + +@section Scripts { } \ No newline at end of file diff --git a/cicm_web/Areas/Identity/Pages/Account/LoginWithRecoveryCode.cshtml.cs b/cicm_web/Areas/Identity/Pages/Account/LoginWithRecoveryCode.cshtml.cs index d5e510b4..01908d25 100644 --- a/cicm_web/Areas/Identity/Pages/Account/LoginWithRecoveryCode.cshtml.cs +++ b/cicm_web/Areas/Identity/Pages/Account/LoginWithRecoveryCode.cshtml.cs @@ -1,4 +1,4 @@ -/****************************************************************************** +/****************************************************************************** // 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 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; @@ -74,7 +74,7 @@ namespace cicm_web.Areas.Identity.Pages.Account if(!ModelState.IsValid) return Page(); 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); diff --git a/cicm_web/Areas/Identity/Pages/Account/Logout.cshtml.cs b/cicm_web/Areas/Identity/Pages/Account/Logout.cshtml.cs index 8890a736..39bb3e76 100644 --- a/cicm_web/Areas/Identity/Pages/Account/Logout.cshtml.cs +++ b/cicm_web/Areas/Identity/Pages/Account/Logout.cshtml.cs @@ -1,4 +1,4 @@ -/****************************************************************************** +/****************************************************************************** // Canary Islands Computer Museum Website // ---------------------------------------------------------------------------- // diff --git a/cicm_web/Areas/Identity/Pages/Account/Manage/ChangePassword.cshtml b/cicm_web/Areas/Identity/Pages/Account/Manage/ChangePassword.cshtml index ff3d6295..479f4107 100644 --- a/cicm_web/Areas/Identity/Pages/Account/Manage/ChangePassword.cshtml +++ b/cicm_web/Areas/Identity/Pages/Account/Manage/ChangePassword.cshtml @@ -33,34 +33,51 @@ @model ChangePasswordModel @{ ViewData["Title"] = "Change password"; + ViewData["ActivePage"] = ManageNavPages.ChangePassword; }

@ViewData["Title"]

-@Html.Partial("_StatusMessage", Model.StatusMessage) +
-
-
+ +
+
- - + + +
- - + + +
- - + + +
- +
@section Scripts { -} +} \ No newline at end of file diff --git a/cicm_web/Areas/Identity/Pages/Account/Manage/ChangePassword.cshtml.cs b/cicm_web/Areas/Identity/Pages/Account/Manage/ChangePassword.cshtml.cs index e6825386..5175213c 100644 --- a/cicm_web/Areas/Identity/Pages/Account/Manage/ChangePassword.cshtml.cs +++ b/cicm_web/Areas/Identity/Pages/Account/Manage/ChangePassword.cshtml.cs @@ -1,4 +1,4 @@ -/****************************************************************************** +/****************************************************************************** // Canary Islands Computer Museum Website // ---------------------------------------------------------------------------- // diff --git a/cicm_web/Areas/Identity/Pages/Account/Manage/DeletePersonalData.cshtml b/cicm_web/Areas/Identity/Pages/Account/Manage/DeletePersonalData.cshtml index 3df6b23a..c1fc7e41 100644 --- a/cicm_web/Areas/Identity/Pages/Account/Manage/DeletePersonalData.cshtml +++ b/cicm_web/Areas/Identity/Pages/Account/Manage/DeletePersonalData.cshtml @@ -33,12 +33,13 @@ @model DeletePersonalDataModel @{ ViewData["Title"] = "Delete Personal Data"; - ViewData["ActivePage"] = ManageNavPages.DeletePersonalData; + ViewData["ActivePage"] = ManageNavPages.PersonalData; }

@ViewData["Title"]

-