From e303dc938f8a96a078e4e579f0690a25edd69bd7 Mon Sep 17 00:00:00 2001 From: Andrew Hoefling Date: Fri, 16 Feb 2018 21:22:33 -0500 Subject: [PATCH] Added draggable component to screen using jquery ui --- Dnn.vNext.sln | 10 +- .../Controllers/AccountController.cs | 33 --- src/Dnn.vNext/Data/ApplicationDbContext.cs | 25 -- src/Dnn.vNext/Data/ApplicationUser.cs | 13 -- ...000000000_CreateIdentitySchema.Designer.cs | 216 ----------------- .../00000000000000_CreateIdentitySchema.cs | 219 ------------------ .../ApplicationDbContextModelSnapshot.cs | 215 ----------------- src/Dnn.vNext/Dnn.vNext.csproj | 6 +- .../Extensions/EmailSenderExtensions.cs | 24 -- .../Extensions/UrlHelperExtensions.cs | 38 --- .../Pages/Account/AccessDenied.cshtml | 10 - .../Pages/Account/AccessDenied.cshtml.cs | 16 -- .../Pages/Account/ConfirmEmail.cshtml | 12 - .../Pages/Account/ConfirmEmail.cshtml.cs | 43 ---- .../Pages/Account/ExternalLogin.cshtml | 33 --- .../Pages/Account/ExternalLogin.cshtml.cs | 133 ----------- .../Pages/Account/ForgotPassword.cshtml | 26 --- .../Pages/Account/ForgotPassword.cshtml.cs | 56 ----- .../Account/ForgotPasswordConfirmation.cshtml | 10 - .../ForgotPasswordConfirmation.cshtml.cs | 16 -- src/Dnn.vNext/Pages/Account/Lockout.cshtml | 10 - src/Dnn.vNext/Pages/Account/Lockout.cshtml.cs | 16 -- src/Dnn.vNext/Pages/Account/Login.cshtml | 82 ------- src/Dnn.vNext/Pages/Account/Login.cshtml.cs | 99 -------- .../Pages/Account/LoginWith2fa.cshtml | 41 ---- .../Pages/Account/LoginWith2fa.cshtml.cs | 95 -------- .../Account/LoginWithRecoveryCode.cshtml | 29 --- .../Account/LoginWithRecoveryCode.cshtml.cs | 88 ------- .../Account/Manage/ChangePassword.cshtml | 35 --- .../Account/Manage/ChangePassword.cshtml.cs | 102 -------- .../Pages/Account/Manage/Disable2fa.cshtml | 25 -- .../Pages/Account/Manage/Disable2fa.cshtml.cs | 61 ----- .../Account/Manage/EnableAuthenticator.cshtml | 53 ----- .../Manage/EnableAuthenticator.cshtml.cs | 139 ----------- .../Account/Manage/ExternalLogins.cshtml | 52 ----- .../Account/Manage/ExternalLogins.cshtml.cs | 108 --------- .../Manage/GenerateRecoveryCodes.cshtml | 27 --- .../Manage/GenerateRecoveryCodes.cshtml.cs | 63 ----- .../Pages/Account/Manage/Index.cshtml | 45 ---- .../Pages/Account/Manage/Index.cshtml.cs | 128 ---------- .../Pages/Account/Manage/ManageNavPages.cs | 34 --- .../Account/Manage/ResetAuthenticator.cshtml | 23 -- .../Manage/ResetAuthenticator.cshtml.cs | 51 ---- .../Pages/Account/Manage/SetPassword.cshtml | 35 --- .../Account/Manage/SetPassword.cshtml.cs | 93 -------- .../Account/Manage/ShowRecoveryCodes.cshtml | 25 -- .../Manage/ShowRecoveryCodes.cshtml.cs | 25 -- .../Manage/TwoFactorAuthentication.cshtml | 49 ---- .../Manage/TwoFactorAuthentication.cshtml.cs | 53 ----- .../Pages/Account/Manage/_Layout.cshtml | 23 -- .../Pages/Account/Manage/_ManageNav.cshtml | 15 -- .../Account/Manage/_StatusMessage.cshtml | 10 - .../Pages/Account/Manage/_ViewImports.cshtml | 1 - src/Dnn.vNext/Pages/Account/Register.cshtml | 37 --- .../Pages/Account/Register.cshtml.cs | 91 -------- .../Pages/Account/ResetPassword.cshtml | 37 --- .../Pages/Account/ResetPassword.cshtml.cs | 87 ------- .../Account/ResetPasswordConfirmation.cshtml | 10 - .../ResetPasswordConfirmation.cshtml.cs | 16 -- src/Dnn.vNext/Pages/Account/SignedOut.cshtml | 10 - .../Pages/Account/SignedOut.cshtml.cs | 20 -- .../Pages/Account/_ViewImports.cshtml | 1 - src/Dnn.vNext/Pages/Demo.cshtml | 11 + src/Dnn.vNext/Pages/_Layout.cshtml | 3 +- src/Dnn.vNext/Pages/_LoginPartial.cshtml | 25 -- src/Dnn.vNext/Pages/_ViewImports.cshtml | 2 - src/Dnn.vNext/Services/EmailSender.cs | 17 -- src/Dnn.vNext/Services/IEmailSender.cs | 12 - src/Dnn.vNext/Startup.cs | 26 +-- src/Dnn.vNext/appsettings.json | 3 - src/Dnn.vNext/wwwroot/css/site.css | 7 + 71 files changed, 27 insertions(+), 3277 deletions(-) delete mode 100644 src/Dnn.vNext/Controllers/AccountController.cs delete mode 100644 src/Dnn.vNext/Data/ApplicationDbContext.cs delete mode 100644 src/Dnn.vNext/Data/ApplicationUser.cs delete mode 100644 src/Dnn.vNext/Data/Migrations/00000000000000_CreateIdentitySchema.Designer.cs delete mode 100644 src/Dnn.vNext/Data/Migrations/00000000000000_CreateIdentitySchema.cs delete mode 100644 src/Dnn.vNext/Data/Migrations/ApplicationDbContextModelSnapshot.cs delete mode 100644 src/Dnn.vNext/Extensions/EmailSenderExtensions.cs delete mode 100644 src/Dnn.vNext/Extensions/UrlHelperExtensions.cs delete mode 100644 src/Dnn.vNext/Pages/Account/AccessDenied.cshtml delete mode 100644 src/Dnn.vNext/Pages/Account/AccessDenied.cshtml.cs delete mode 100644 src/Dnn.vNext/Pages/Account/ConfirmEmail.cshtml delete mode 100644 src/Dnn.vNext/Pages/Account/ConfirmEmail.cshtml.cs delete mode 100644 src/Dnn.vNext/Pages/Account/ExternalLogin.cshtml delete mode 100644 src/Dnn.vNext/Pages/Account/ExternalLogin.cshtml.cs delete mode 100644 src/Dnn.vNext/Pages/Account/ForgotPassword.cshtml delete mode 100644 src/Dnn.vNext/Pages/Account/ForgotPassword.cshtml.cs delete mode 100644 src/Dnn.vNext/Pages/Account/ForgotPasswordConfirmation.cshtml delete mode 100644 src/Dnn.vNext/Pages/Account/ForgotPasswordConfirmation.cshtml.cs delete mode 100644 src/Dnn.vNext/Pages/Account/Lockout.cshtml delete mode 100644 src/Dnn.vNext/Pages/Account/Lockout.cshtml.cs delete mode 100644 src/Dnn.vNext/Pages/Account/Login.cshtml delete mode 100644 src/Dnn.vNext/Pages/Account/Login.cshtml.cs delete mode 100644 src/Dnn.vNext/Pages/Account/LoginWith2fa.cshtml delete mode 100644 src/Dnn.vNext/Pages/Account/LoginWith2fa.cshtml.cs delete mode 100644 src/Dnn.vNext/Pages/Account/LoginWithRecoveryCode.cshtml delete mode 100644 src/Dnn.vNext/Pages/Account/LoginWithRecoveryCode.cshtml.cs delete mode 100644 src/Dnn.vNext/Pages/Account/Manage/ChangePassword.cshtml delete mode 100644 src/Dnn.vNext/Pages/Account/Manage/ChangePassword.cshtml.cs delete mode 100644 src/Dnn.vNext/Pages/Account/Manage/Disable2fa.cshtml delete mode 100644 src/Dnn.vNext/Pages/Account/Manage/Disable2fa.cshtml.cs delete mode 100644 src/Dnn.vNext/Pages/Account/Manage/EnableAuthenticator.cshtml delete mode 100644 src/Dnn.vNext/Pages/Account/Manage/EnableAuthenticator.cshtml.cs delete mode 100644 src/Dnn.vNext/Pages/Account/Manage/ExternalLogins.cshtml delete mode 100644 src/Dnn.vNext/Pages/Account/Manage/ExternalLogins.cshtml.cs delete mode 100644 src/Dnn.vNext/Pages/Account/Manage/GenerateRecoveryCodes.cshtml delete mode 100644 src/Dnn.vNext/Pages/Account/Manage/GenerateRecoveryCodes.cshtml.cs delete mode 100644 src/Dnn.vNext/Pages/Account/Manage/Index.cshtml delete mode 100644 src/Dnn.vNext/Pages/Account/Manage/Index.cshtml.cs delete mode 100644 src/Dnn.vNext/Pages/Account/Manage/ManageNavPages.cs delete mode 100644 src/Dnn.vNext/Pages/Account/Manage/ResetAuthenticator.cshtml delete mode 100644 src/Dnn.vNext/Pages/Account/Manage/ResetAuthenticator.cshtml.cs delete mode 100644 src/Dnn.vNext/Pages/Account/Manage/SetPassword.cshtml delete mode 100644 src/Dnn.vNext/Pages/Account/Manage/SetPassword.cshtml.cs delete mode 100644 src/Dnn.vNext/Pages/Account/Manage/ShowRecoveryCodes.cshtml delete mode 100644 src/Dnn.vNext/Pages/Account/Manage/ShowRecoveryCodes.cshtml.cs delete mode 100644 src/Dnn.vNext/Pages/Account/Manage/TwoFactorAuthentication.cshtml delete mode 100644 src/Dnn.vNext/Pages/Account/Manage/TwoFactorAuthentication.cshtml.cs delete mode 100644 src/Dnn.vNext/Pages/Account/Manage/_Layout.cshtml delete mode 100644 src/Dnn.vNext/Pages/Account/Manage/_ManageNav.cshtml delete mode 100644 src/Dnn.vNext/Pages/Account/Manage/_StatusMessage.cshtml delete mode 100644 src/Dnn.vNext/Pages/Account/Manage/_ViewImports.cshtml delete mode 100644 src/Dnn.vNext/Pages/Account/Register.cshtml delete mode 100644 src/Dnn.vNext/Pages/Account/Register.cshtml.cs delete mode 100644 src/Dnn.vNext/Pages/Account/ResetPassword.cshtml delete mode 100644 src/Dnn.vNext/Pages/Account/ResetPassword.cshtml.cs delete mode 100644 src/Dnn.vNext/Pages/Account/ResetPasswordConfirmation.cshtml delete mode 100644 src/Dnn.vNext/Pages/Account/ResetPasswordConfirmation.cshtml.cs delete mode 100644 src/Dnn.vNext/Pages/Account/SignedOut.cshtml delete mode 100644 src/Dnn.vNext/Pages/Account/SignedOut.cshtml.cs delete mode 100644 src/Dnn.vNext/Pages/Account/_ViewImports.cshtml delete mode 100644 src/Dnn.vNext/Pages/_LoginPartial.cshtml delete mode 100644 src/Dnn.vNext/Services/EmailSender.cs delete mode 100644 src/Dnn.vNext/Services/IEmailSender.cs diff --git a/Dnn.vNext.sln b/Dnn.vNext.sln index 2f495f9..7194462 100644 --- a/Dnn.vNext.sln +++ b/Dnn.vNext.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.27130.2024 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dnn.vNext", "src\Dnn.vNext\Dnn.vNext.csproj", "{81CAB28B-2C86-49E6-B5E8-21FD5EEDC929}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dnn.vNext", "src\Dnn.vNext\Dnn.vNext.csproj", "{32DEE0AB-435A-410D-B447-B046501B1160}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -11,10 +11,10 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {81CAB28B-2C86-49E6-B5E8-21FD5EEDC929}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {81CAB28B-2C86-49E6-B5E8-21FD5EEDC929}.Debug|Any CPU.Build.0 = Debug|Any CPU - {81CAB28B-2C86-49E6-B5E8-21FD5EEDC929}.Release|Any CPU.ActiveCfg = Release|Any CPU - {81CAB28B-2C86-49E6-B5E8-21FD5EEDC929}.Release|Any CPU.Build.0 = Release|Any CPU + {32DEE0AB-435A-410D-B447-B046501B1160}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {32DEE0AB-435A-410D-B447-B046501B1160}.Debug|Any CPU.Build.0 = Debug|Any CPU + {32DEE0AB-435A-410D-B447-B046501B1160}.Release|Any CPU.ActiveCfg = Release|Any CPU + {32DEE0AB-435A-410D-B447-B046501B1160}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/Dnn.vNext/Controllers/AccountController.cs b/src/Dnn.vNext/Controllers/AccountController.cs deleted file mode 100644 index 81cc89f..0000000 --- a/src/Dnn.vNext/Controllers/AccountController.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Identity; -using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Logging; -using Dnn.vNext.Data; - -namespace Dnn.vNext.Controllers -{ - [Route("[controller]/[action]")] - public class AccountController : Controller - { - private readonly SignInManager _signInManager; - private readonly ILogger _logger; - - public AccountController(SignInManager signInManager, ILogger logger) - { - _signInManager = signInManager; - _logger = logger; - } - - [HttpPost] - [ValidateAntiForgeryToken] - public async Task Logout() - { - await _signInManager.SignOutAsync(); - _logger.LogInformation("User logged out."); - return RedirectToPage("/Index"); - } - } -} diff --git a/src/Dnn.vNext/Data/ApplicationDbContext.cs b/src/Dnn.vNext/Data/ApplicationDbContext.cs deleted file mode 100644 index 7b329b3..0000000 --- a/src/Dnn.vNext/Data/ApplicationDbContext.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Identity.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore; - -namespace Dnn.vNext.Data -{ - public class ApplicationDbContext : IdentityDbContext - { - public ApplicationDbContext(DbContextOptions options) - : base(options) - { - } - - protected override void OnModelCreating(ModelBuilder builder) - { - base.OnModelCreating(builder); - // Customize the ASP.NET Identity model and override the defaults if needed. - // For example, you can rename the ASP.NET Identity table names and more. - // Add your customizations after calling base.OnModelCreating(builder); - } - } -} diff --git a/src/Dnn.vNext/Data/ApplicationUser.cs b/src/Dnn.vNext/Data/ApplicationUser.cs deleted file mode 100644 index a6a64ef..0000000 --- a/src/Dnn.vNext/Data/ApplicationUser.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Identity; - -namespace Dnn.vNext.Data -{ - // Add profile data for application users by adding properties to the ApplicationUser class - public class ApplicationUser : IdentityUser - { - } -} diff --git a/src/Dnn.vNext/Data/Migrations/00000000000000_CreateIdentitySchema.Designer.cs b/src/Dnn.vNext/Data/Migrations/00000000000000_CreateIdentitySchema.Designer.cs deleted file mode 100644 index f281f23..0000000 --- a/src/Dnn.vNext/Data/Migrations/00000000000000_CreateIdentitySchema.Designer.cs +++ /dev/null @@ -1,216 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; - -namespace Dnn.vNext.Data.Migrations -{ - [DbContext(typeof(ApplicationDbContext))] - [Migration("00000000000000_CreateIdentitySchema")] - partial class CreateIdentitySchema - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { - modelBuilder - .HasAnnotation("ProductVersion", "1.0.0-rc3") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => - { - b.Property("Id"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken(); - - b.Property("Name") - .HasAnnotation("MaxLength", 256); - - b.Property("NormalizedName") - .HasAnnotation("MaxLength", 256); - - b.HasKey("Id"); - - b.HasIndex("NormalizedName") - .HasName("RoleNameIndex"); - - b.ToTable("AspNetRoles"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("ClaimType"); - - b.Property("ClaimValue"); - - b.Property("RoleId") - .IsRequired(); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetRoleClaims"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("ClaimType"); - - b.Property("ClaimValue"); - - b.Property("UserId") - .IsRequired(); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserClaims"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.Property("LoginProvider"); - - b.Property("ProviderKey"); - - b.Property("ProviderDisplayName"); - - b.Property("UserId") - .IsRequired(); - - b.HasKey("LoginProvider", "ProviderKey"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserLogins"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.Property("UserId"); - - b.Property("RoleId"); - - b.HasKey("UserId", "RoleId"); - - b.HasIndex("RoleId"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserRoles"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.Property("UserId"); - - b.Property("LoginProvider"); - - b.Property("Name"); - - b.Property("Value"); - - b.HasKey("UserId", "LoginProvider", "Name"); - - b.ToTable("AspNetUserTokens"); - }); - - modelBuilder.Entity("Dnn.vNext.Models.ApplicationUser", b => - { - b.Property("Id"); - - b.Property("AccessFailedCount"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken(); - - b.Property("Email") - .HasAnnotation("MaxLength", 256); - - b.Property("EmailConfirmed"); - - b.Property("LockoutEnabled"); - - b.Property("LockoutEnd"); - - b.Property("NormalizedEmail") - .HasAnnotation("MaxLength", 256); - - b.Property("NormalizedUserName") - .HasAnnotation("MaxLength", 256); - - b.Property("PasswordHash"); - - b.Property("PhoneNumber"); - - b.Property("PhoneNumberConfirmed"); - - b.Property("SecurityStamp"); - - b.Property("TwoFactorEnabled"); - - b.Property("UserName") - .HasAnnotation("MaxLength", 256); - - b.HasKey("Id"); - - b.HasIndex("NormalizedEmail") - .HasName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasName("UserNameIndex"); - - b.ToTable("AspNetUsers"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole") - .WithMany("Claims") - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.HasOne("Dnn.vNext.Models.ApplicationUser") - .WithMany("Claims") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.HasOne("Dnn.vNext.Models.ApplicationUser") - .WithMany("Logins") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole") - .WithMany("Users") - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("Dnn.vNext.Models.ApplicationUser") - .WithMany("Roles") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade); - }); - } - } -} diff --git a/src/Dnn.vNext/Data/Migrations/00000000000000_CreateIdentitySchema.cs b/src/Dnn.vNext/Data/Migrations/00000000000000_CreateIdentitySchema.cs deleted file mode 100644 index 4cfa309..0000000 --- a/src/Dnn.vNext/Data/Migrations/00000000000000_CreateIdentitySchema.cs +++ /dev/null @@ -1,219 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; - -namespace Dnn.vNext.Data.Migrations -{ - public partial class CreateIdentitySchema : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "AspNetRoles", - columns: table => new - { - Id = table.Column(nullable: false), - ConcurrencyStamp = table.Column(nullable: true), - Name = table.Column(maxLength: 256, nullable: true), - NormalizedName = table.Column(maxLength: 256, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetRoles", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AspNetUserTokens", - columns: table => new - { - UserId = table.Column(nullable: false), - LoginProvider = table.Column(nullable: false), - Name = table.Column(nullable: false), - Value = table.Column(nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name }); - }); - - migrationBuilder.CreateTable( - name: "AspNetUsers", - columns: table => new - { - Id = table.Column(nullable: false), - AccessFailedCount = table.Column(nullable: false), - ConcurrencyStamp = table.Column(nullable: true), - Email = table.Column(maxLength: 256, nullable: true), - EmailConfirmed = table.Column(nullable: false), - LockoutEnabled = table.Column(nullable: false), - LockoutEnd = table.Column(nullable: true), - NormalizedEmail = table.Column(maxLength: 256, nullable: true), - NormalizedUserName = table.Column(maxLength: 256, nullable: true), - PasswordHash = table.Column(nullable: true), - PhoneNumber = table.Column(nullable: true), - PhoneNumberConfirmed = table.Column(nullable: false), - SecurityStamp = table.Column(nullable: true), - TwoFactorEnabled = table.Column(nullable: false), - UserName = table.Column(maxLength: 256, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetUsers", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AspNetRoleClaims", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), - ClaimType = table.Column(nullable: true), - ClaimValue = table.Column(nullable: true), - RoleId = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id); - table.ForeignKey( - name: "FK_AspNetRoleClaims_AspNetRoles_RoleId", - column: x => x.RoleId, - principalTable: "AspNetRoles", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AspNetUserClaims", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), - ClaimType = table.Column(nullable: true), - ClaimValue = table.Column(nullable: true), - UserId = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetUserClaims", x => x.Id); - table.ForeignKey( - name: "FK_AspNetUserClaims_AspNetUsers_UserId", - column: x => x.UserId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AspNetUserLogins", - columns: table => new - { - LoginProvider = table.Column(nullable: false), - ProviderKey = table.Column(nullable: false), - ProviderDisplayName = table.Column(nullable: true), - UserId = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey }); - table.ForeignKey( - name: "FK_AspNetUserLogins_AspNetUsers_UserId", - column: x => x.UserId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AspNetUserRoles", - columns: table => new - { - UserId = table.Column(nullable: false), - RoleId = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId }); - table.ForeignKey( - name: "FK_AspNetUserRoles_AspNetRoles_RoleId", - column: x => x.RoleId, - principalTable: "AspNetRoles", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_AspNetUserRoles_AspNetUsers_UserId", - column: x => x.UserId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "RoleNameIndex", - table: "AspNetRoles", - column: "NormalizedName"); - - migrationBuilder.CreateIndex( - name: "IX_AspNetRoleClaims_RoleId", - table: "AspNetRoleClaims", - column: "RoleId"); - - migrationBuilder.CreateIndex( - name: "IX_AspNetUserClaims_UserId", - table: "AspNetUserClaims", - column: "UserId"); - - migrationBuilder.CreateIndex( - name: "IX_AspNetUserLogins_UserId", - table: "AspNetUserLogins", - column: "UserId"); - - migrationBuilder.CreateIndex( - name: "IX_AspNetUserRoles_RoleId", - table: "AspNetUserRoles", - column: "RoleId"); - - migrationBuilder.CreateIndex( - name: "IX_AspNetUserRoles_UserId", - table: "AspNetUserRoles", - column: "UserId"); - - migrationBuilder.CreateIndex( - name: "EmailIndex", - table: "AspNetUsers", - column: "NormalizedEmail"); - - migrationBuilder.CreateIndex( - name: "UserNameIndex", - table: "AspNetUsers", - column: "NormalizedUserName", - unique: true); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "AspNetRoleClaims"); - - migrationBuilder.DropTable( - name: "AspNetUserClaims"); - - migrationBuilder.DropTable( - name: "AspNetUserLogins"); - - migrationBuilder.DropTable( - name: "AspNetUserRoles"); - - migrationBuilder.DropTable( - name: "AspNetUserTokens"); - - migrationBuilder.DropTable( - name: "AspNetRoles"); - - migrationBuilder.DropTable( - name: "AspNetUsers"); - } - } -} diff --git a/src/Dnn.vNext/Data/Migrations/ApplicationDbContextModelSnapshot.cs b/src/Dnn.vNext/Data/Migrations/ApplicationDbContextModelSnapshot.cs deleted file mode 100644 index f433a2e..0000000 --- a/src/Dnn.vNext/Data/Migrations/ApplicationDbContextModelSnapshot.cs +++ /dev/null @@ -1,215 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; - -namespace Dnn.vNext.Data.Migrations -{ - [DbContext(typeof(ApplicationDbContext))] - partial class ApplicationDbContextModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { - modelBuilder - .HasAnnotation("ProductVersion", "1.0.0-rc3") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityRole", b => - { - b.Property("Id"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken(); - - b.Property("Name") - .HasAnnotation("MaxLength", 256); - - b.Property("NormalizedName") - .HasAnnotation("MaxLength", 256); - - b.HasKey("Id"); - - b.HasIndex("NormalizedName") - .HasName("RoleNameIndex"); - - b.ToTable("AspNetRoles"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityRoleClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("ClaimType"); - - b.Property("ClaimValue"); - - b.Property("RoleId") - .IsRequired(); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetRoleClaims"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("ClaimType"); - - b.Property("ClaimValue"); - - b.Property("UserId") - .IsRequired(); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserClaims"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserLogin", b => - { - b.Property("LoginProvider"); - - b.Property("ProviderKey"); - - b.Property("ProviderDisplayName"); - - b.Property("UserId") - .IsRequired(); - - b.HasKey("LoginProvider", "ProviderKey"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserLogins"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserRole", b => - { - b.Property("UserId"); - - b.Property("RoleId"); - - b.HasKey("UserId", "RoleId"); - - b.HasIndex("RoleId"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserRoles"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserToken", b => - { - b.Property("UserId"); - - b.Property("LoginProvider"); - - b.Property("Name"); - - b.Property("Value"); - - b.HasKey("UserId", "LoginProvider", "Name"); - - b.ToTable("AspNetUserTokens"); - }); - - modelBuilder.Entity("Dnn.vNext.Models.ApplicationUser", b => - { - b.Property("Id"); - - b.Property("AccessFailedCount"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken(); - - b.Property("Email") - .HasAnnotation("MaxLength", 256); - - b.Property("EmailConfirmed"); - - b.Property("LockoutEnabled"); - - b.Property("LockoutEnd"); - - b.Property("NormalizedEmail") - .HasAnnotation("MaxLength", 256); - - b.Property("NormalizedUserName") - .HasAnnotation("MaxLength", 256); - - b.Property("PasswordHash"); - - b.Property("PhoneNumber"); - - b.Property("PhoneNumberConfirmed"); - - b.Property("SecurityStamp"); - - b.Property("TwoFactorEnabled"); - - b.Property("UserName") - .HasAnnotation("MaxLength", 256); - - b.HasKey("Id"); - - b.HasIndex("NormalizedEmail") - .HasName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasName("UserNameIndex"); - - b.ToTable("AspNetUsers"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityRoleClaim", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityRole") - .WithMany("Claims") - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserClaim", b => - { - b.HasOne("Dnn.vNext.Models.ApplicationUser") - .WithMany("Claims") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserLogin", b => - { - b.HasOne("Dnn.vNext.Models.ApplicationUser") - .WithMany("Logins") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserRole", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityRole") - .WithMany("Users") - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("Dnn.vNext.Models.ApplicationUser") - .WithMany("Roles") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade); - }); - } - } -} diff --git a/src/Dnn.vNext/Dnn.vNext.csproj b/src/Dnn.vNext/Dnn.vNext.csproj index 1d3bb16..e1c03ce 100644 --- a/src/Dnn.vNext/Dnn.vNext.csproj +++ b/src/Dnn.vNext/Dnn.vNext.csproj @@ -1,16 +1,12 @@ netcoreapp2.0 - aspnet-Dnn.vNext-6C1141F5-5E0E-42F9-9DE6-E03C2CD4DF47 - - + - - diff --git a/src/Dnn.vNext/Extensions/EmailSenderExtensions.cs b/src/Dnn.vNext/Extensions/EmailSenderExtensions.cs deleted file mode 100644 index da0702d..0000000 --- a/src/Dnn.vNext/Extensions/EmailSenderExtensions.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text.Encodings.Web; -using System.Threading.Tasks; -using Dnn.vNext.Services; - -namespace Dnn.vNext.Services -{ - public static class EmailSenderExtensions - { - public static Task SendEmailConfirmationAsync(this IEmailSender emailSender, string email, string link) - { - return emailSender.SendEmailAsync(email, "Confirm your email", - $"Please confirm your account by clicking here."); - } - - public static Task SendResetPasswordAsync(this IEmailSender emailSender, string email, string callbackUrl) - { - return emailSender.SendEmailAsync(email, "Reset Password", - $"Please reset your password by clicking here."); - } - } -} diff --git a/src/Dnn.vNext/Extensions/UrlHelperExtensions.cs b/src/Dnn.vNext/Extensions/UrlHelperExtensions.cs deleted file mode 100644 index 4caa644..0000000 --- a/src/Dnn.vNext/Extensions/UrlHelperExtensions.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace Microsoft.AspNetCore.Mvc -{ - public static class UrlHelperExtensions - { - public static string GetLocalUrl(this IUrlHelper urlHelper, string localUrl) - { - if (!urlHelper.IsLocalUrl(localUrl)) - { - return urlHelper.Page("/Index"); - } - - return localUrl; - } - - public static string EmailConfirmationLink(this IUrlHelper urlHelper, string userId, string code, string scheme) - { - return urlHelper.Page( - "/Account/ConfirmEmail", - pageHandler: null, - values: new { userId, code }, - protocol: scheme); - } - - public static string ResetPasswordCallbackLink(this IUrlHelper urlHelper, string userId, string code, string scheme) - { - return urlHelper.Page( - "/Account/ResetPassword", - pageHandler: null, - values: new { userId, code }, - protocol: scheme); - } - } -} diff --git a/src/Dnn.vNext/Pages/Account/AccessDenied.cshtml b/src/Dnn.vNext/Pages/Account/AccessDenied.cshtml deleted file mode 100644 index 3510ede..0000000 --- a/src/Dnn.vNext/Pages/Account/AccessDenied.cshtml +++ /dev/null @@ -1,10 +0,0 @@ -@page -@model AccessDeniedModel -@{ - ViewData["Title"] = "Access denied"; -} - -
-

@ViewData["Title"]

-

You do not have access to this resource.

-
diff --git a/src/Dnn.vNext/Pages/Account/AccessDenied.cshtml.cs b/src/Dnn.vNext/Pages/Account/AccessDenied.cshtml.cs deleted file mode 100644 index b9890eb..0000000 --- a/src/Dnn.vNext/Pages/Account/AccessDenied.cshtml.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc.RazorPages; - -namespace Dnn.vNext.Pages.Account -{ - public class AccessDeniedModel : PageModel - { - public void OnGet() - { - - } - } -} diff --git a/src/Dnn.vNext/Pages/Account/ConfirmEmail.cshtml b/src/Dnn.vNext/Pages/Account/ConfirmEmail.cshtml deleted file mode 100644 index 9038964..0000000 --- a/src/Dnn.vNext/Pages/Account/ConfirmEmail.cshtml +++ /dev/null @@ -1,12 +0,0 @@ -@page -@model ConfirmEmailModel -@{ - ViewData["Title"] = "Confirm email"; -} - -

@ViewData["Title"]

-
-

- Thank you for confirming your email. -

-
diff --git a/src/Dnn.vNext/Pages/Account/ConfirmEmail.cshtml.cs b/src/Dnn.vNext/Pages/Account/ConfirmEmail.cshtml.cs deleted file mode 100644 index 5b338fb..0000000 --- a/src/Dnn.vNext/Pages/Account/ConfirmEmail.cshtml.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Identity; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; -using Dnn.vNext.Data; - -namespace Dnn.vNext.Pages.Account -{ - public class ConfirmEmailModel : PageModel - { - private readonly UserManager _userManager; - - public ConfirmEmailModel(UserManager userManager) - { - _userManager = userManager; - } - - public async Task OnGetAsync(string userId, string code) - { - if (userId == null || code == null) - { - return RedirectToPage("/Index"); - } - - var user = await _userManager.FindByIdAsync(userId); - if (user == null) - { - throw new ApplicationException($"Unable to load user with ID '{userId}'."); - } - - var result = await _userManager.ConfirmEmailAsync(user, code); - if (!result.Succeeded) - { - throw new ApplicationException($"Error confirming email for user with ID '{userId}':"); - } - - return Page(); - } - } -} diff --git a/src/Dnn.vNext/Pages/Account/ExternalLogin.cshtml b/src/Dnn.vNext/Pages/Account/ExternalLogin.cshtml deleted file mode 100644 index 51c9b92..0000000 --- a/src/Dnn.vNext/Pages/Account/ExternalLogin.cshtml +++ /dev/null @@ -1,33 +0,0 @@ -@page -@model ExternalLoginModel -@{ - ViewData["Title"] = "Register"; -} - -

@ViewData["Title"]

-

Associate your @Model.LoginProvider account.

-
- -

- You've successfully authenticated with @Model.LoginProvider. - Please enter an email address for this site below and click the Register button to finish - logging in. -

- -
-
-
-
-
- - - -
- -
-
-
- -@section Scripts { - @await Html.PartialAsync("_ValidationScriptsPartial") -} diff --git a/src/Dnn.vNext/Pages/Account/ExternalLogin.cshtml.cs b/src/Dnn.vNext/Pages/Account/ExternalLogin.cshtml.cs deleted file mode 100644 index fb21952..0000000 --- a/src/Dnn.vNext/Pages/Account/ExternalLogin.cshtml.cs +++ /dev/null @@ -1,133 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Linq; -using System.Security.Claims; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Identity; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; -using Microsoft.Extensions.Logging; -using Dnn.vNext.Data; - -namespace Dnn.vNext.Pages.Account -{ - public class ExternalLoginModel : PageModel - { - private readonly SignInManager _signInManager; - private readonly UserManager _userManager; - private readonly ILogger _logger; - - public ExternalLoginModel( - SignInManager signInManager, - UserManager userManager, - ILogger logger) - { - _signInManager = signInManager; - _userManager = userManager; - _logger = logger; - } - - [BindProperty] - public InputModel Input { get; set; } - - public string LoginProvider { get; set; } - - public string ReturnUrl { get; set; } - - [TempData] - public string ErrorMessage { get; set; } - - public class InputModel - { - [Required] - [EmailAddress] - public string Email { get; set; } - } - - public IActionResult OnGetAsync() - { - return RedirectToPage("./Login"); - } - - public IActionResult OnPost(string provider, string returnUrl = null) - { - // Request a redirect to the external login provider. - var redirectUrl = Url.Page("./ExternalLogin", pageHandler: "Callback", values: new { returnUrl }); - var properties = _signInManager.ConfigureExternalAuthenticationProperties(provider, redirectUrl); - return new ChallengeResult(provider, properties); - } - - public async Task OnGetCallbackAsync(string returnUrl = null, string remoteError = null) - { - if (remoteError != null) - { - ErrorMessage = $"Error from external provider: {remoteError}"; - return RedirectToPage("./Login"); - } - var info = await _signInManager.GetExternalLoginInfoAsync(); - if (info == null) - { - return RedirectToPage("./Login"); - } - - // Sign in the user with this external login provider if the user already has a login. - var result = await _signInManager.ExternalLoginSignInAsync(info.LoginProvider, info.ProviderKey, isPersistent: false, bypassTwoFactor : true); - if (result.Succeeded) - { - _logger.LogInformation("{Name} logged in with {LoginProvider} provider.", info.Principal.Identity.Name, info.LoginProvider); - return LocalRedirect(Url.GetLocalUrl(returnUrl)); - } - if (result.IsLockedOut) - { - return RedirectToPage("./Lockout"); - } - else - { - // If the user does not have an account, then ask the user to create an account. - ReturnUrl = returnUrl; - LoginProvider = info.LoginProvider; - if (info.Principal.HasClaim(c => c.Type == ClaimTypes.Email)) - { - Input = new InputModel - { - Email = info.Principal.FindFirstValue(ClaimTypes.Email) - }; - } - return Page(); - } - } - - public async Task OnPostConfirmationAsync(string returnUrl = null) - { - if (ModelState.IsValid) - { - // Get the information about the user from the external login provider - var info = await _signInManager.GetExternalLoginInfoAsync(); - if (info == null) - { - throw new ApplicationException("Error loading external login information during confirmation."); - } - var user = new ApplicationUser { UserName = Input.Email, Email = Input.Email }; - var result = await _userManager.CreateAsync(user); - if (result.Succeeded) - { - result = await _userManager.AddLoginAsync(user, info); - if (result.Succeeded) - { - await _signInManager.SignInAsync(user, isPersistent: false); - _logger.LogInformation("User created an account using {Name} provider.", info.LoginProvider); - return LocalRedirect(Url.GetLocalUrl(returnUrl)); - } - } - foreach (var error in result.Errors) - { - ModelState.AddModelError(string.Empty, error.Description); - } - } - - ReturnUrl = returnUrl; - return Page(); - } - } -} diff --git a/src/Dnn.vNext/Pages/Account/ForgotPassword.cshtml b/src/Dnn.vNext/Pages/Account/ForgotPassword.cshtml deleted file mode 100644 index cd8e98c..0000000 --- a/src/Dnn.vNext/Pages/Account/ForgotPassword.cshtml +++ /dev/null @@ -1,26 +0,0 @@ -@page -@model ForgotPasswordModel -@{ - ViewData["Title"] = "Forgot your password?"; -} - -

@ViewData["Title"]

-

Enter your email.

-
-
-
-
-
-
- - - -
- -
-
-
- -@section Scripts { - @await Html.PartialAsync("_ValidationScriptsPartial") -} diff --git a/src/Dnn.vNext/Pages/Account/ForgotPassword.cshtml.cs b/src/Dnn.vNext/Pages/Account/ForgotPassword.cshtml.cs deleted file mode 100644 index df1b1a9..0000000 --- a/src/Dnn.vNext/Pages/Account/ForgotPassword.cshtml.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Identity; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; -using Dnn.vNext.Data; -using Dnn.vNext.Services; - -namespace Dnn.vNext.Pages.Account -{ - public class ForgotPasswordModel : PageModel - { - private readonly UserManager _userManager; - private readonly IEmailSender _emailSender; - - public ForgotPasswordModel(UserManager userManager, IEmailSender emailSender) - { - _userManager = userManager; - _emailSender = emailSender; - } - - [BindProperty] - public InputModel Input { get; set; } - - public class InputModel - { - [Required] - [EmailAddress] - public string Email { get; set; } - } - - public async Task OnPostAsync() - { - if (ModelState.IsValid) - { - var user = await _userManager.FindByEmailAsync(Input.Email); - if (user == null || !(await _userManager.IsEmailConfirmedAsync(user))) - { - // Don't reveal that the user does not exist or is not confirmed - return RedirectToPage("./ForgotPasswordConfirmation"); - } - - // For more information on how to enable account confirmation and password reset please - // visit https://go.microsoft.com/fwlink/?LinkID=532713 - var code = await _userManager.GeneratePasswordResetTokenAsync(user); - var callbackUrl = Url.ResetPasswordCallbackLink(user.Id, code, Request.Scheme); - await _emailSender.SendResetPasswordAsync(Input.Email, callbackUrl); - return RedirectToPage("./ForgotPasswordConfirmation"); - } - - return Page(); - } - } -} diff --git a/src/Dnn.vNext/Pages/Account/ForgotPasswordConfirmation.cshtml b/src/Dnn.vNext/Pages/Account/ForgotPasswordConfirmation.cshtml deleted file mode 100644 index b113930..0000000 --- a/src/Dnn.vNext/Pages/Account/ForgotPasswordConfirmation.cshtml +++ /dev/null @@ -1,10 +0,0 @@ -@page -@model ForgotPasswordConfirmation -@{ - ViewData["Title"] = "Forgot password confirmation"; -} - -

@ViewData["Title"]

-

- Please check your email to reset your password. -

diff --git a/src/Dnn.vNext/Pages/Account/ForgotPasswordConfirmation.cshtml.cs b/src/Dnn.vNext/Pages/Account/ForgotPasswordConfirmation.cshtml.cs deleted file mode 100644 index 4b28808..0000000 --- a/src/Dnn.vNext/Pages/Account/ForgotPasswordConfirmation.cshtml.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc.RazorPages; - -namespace Dnn.vNext.Pages.Account -{ - public class ForgotPasswordConfirmation : PageModel - { - public void OnGet() - { - - } - } -} diff --git a/src/Dnn.vNext/Pages/Account/Lockout.cshtml b/src/Dnn.vNext/Pages/Account/Lockout.cshtml deleted file mode 100644 index 4eded88..0000000 --- a/src/Dnn.vNext/Pages/Account/Lockout.cshtml +++ /dev/null @@ -1,10 +0,0 @@ -@page -@model LockoutModel -@{ - ViewData["Title"] = "Locked out"; -} - -
-

@ViewData["Title"]

-

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

-
diff --git a/src/Dnn.vNext/Pages/Account/Lockout.cshtml.cs b/src/Dnn.vNext/Pages/Account/Lockout.cshtml.cs deleted file mode 100644 index f8ad1c2..0000000 --- a/src/Dnn.vNext/Pages/Account/Lockout.cshtml.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc.RazorPages; - -namespace Dnn.vNext.Pages.Account -{ - public class LockoutModel : PageModel - { - public void OnGet() - { - - } - } -} diff --git a/src/Dnn.vNext/Pages/Account/Login.cshtml b/src/Dnn.vNext/Pages/Account/Login.cshtml deleted file mode 100644 index a486f27..0000000 --- a/src/Dnn.vNext/Pages/Account/Login.cshtml +++ /dev/null @@ -1,82 +0,0 @@ -@page -@model LoginModel - -@{ - ViewData["Title"] = "Log in"; -} - -

@ViewData["Title"]

-
-
-
-
-

Use a local account to log in.

-
-
-
- - - -
-
- - - -
-
-
- -
-
-
- -
- -
-
-
-
-
-

Use another service to log in.

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

- There are no external authentication services configured. See this article - for details on setting up this ASP.NET application to support logging in via external services. -

-
- } - else - { -
-
-

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

-
-
- } - } -
-
-
- -@section Scripts { - @await Html.PartialAsync("_ValidationScriptsPartial") -} diff --git a/src/Dnn.vNext/Pages/Account/Login.cshtml.cs b/src/Dnn.vNext/Pages/Account/Login.cshtml.cs deleted file mode 100644 index 6774fc4..0000000 --- a/src/Dnn.vNext/Pages/Account/Login.cshtml.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Authentication; -using Microsoft.AspNetCore.Identity; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; -using Microsoft.Extensions.Logging; -using Dnn.vNext.Data; - -namespace Dnn.vNext.Pages.Account -{ - public class LoginModel : PageModel - { - private readonly SignInManager _signInManager; - private readonly ILogger _logger; - - public LoginModel(SignInManager signInManager, ILogger logger) - { - _signInManager = signInManager; - _logger = logger; - } - - [BindProperty] - public InputModel Input { get; set; } - - public IList ExternalLogins { get; set; } - - public string ReturnUrl { get; set; } - - [TempData] - public string ErrorMessage { get; set; } - - public class InputModel - { - [Required] - [EmailAddress] - public string Email { get; set; } - - [Required] - [DataType(DataType.Password)] - public string Password { get; set; } - - [Display(Name = "Remember me?")] - public bool RememberMe { get; set; } - } - - public async Task OnGetAsync(string returnUrl = null) - { - if (!string.IsNullOrEmpty(ErrorMessage)) - { - ModelState.AddModelError(string.Empty, ErrorMessage); - } - - // Clear the existing external cookie to ensure a clean login process - await HttpContext.SignOutAsync(IdentityConstants.ExternalScheme); - - ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList(); - - ReturnUrl = returnUrl; - } - - public async Task OnPostAsync(string returnUrl = null) - { - ReturnUrl = returnUrl; - - if (ModelState.IsValid) - { - // This doesn't count login failures towards account lockout - // To enable password failures to trigger account lockout, set lockoutOnFailure: true - var result = await _signInManager.PasswordSignInAsync(Input.Email, Input.Password, Input.RememberMe, lockoutOnFailure: true); - if (result.Succeeded) - { - _logger.LogInformation("User logged in."); - return LocalRedirect(Url.GetLocalUrl(returnUrl)); - } - if (result.RequiresTwoFactor) - { - return RedirectToPage("./LoginWith2fa", new { ReturnUrl = returnUrl, RememberMe = Input.RememberMe }); - } - if (result.IsLockedOut) - { - _logger.LogWarning("User account locked out."); - return RedirectToPage("./Lockout"); - } - else - { - ModelState.AddModelError(string.Empty, "Invalid login attempt."); - return Page(); - } - } - - // If we got this far, something failed, redisplay form - return Page(); - } - } -} diff --git a/src/Dnn.vNext/Pages/Account/LoginWith2fa.cshtml b/src/Dnn.vNext/Pages/Account/LoginWith2fa.cshtml deleted file mode 100644 index 032ecd9..0000000 --- a/src/Dnn.vNext/Pages/Account/LoginWith2fa.cshtml +++ /dev/null @@ -1,41 +0,0 @@ -@page -@model LoginWith2faModel -@{ - ViewData["Title"] = "Two-factor authentication"; -} - -

@ViewData["Title"]

-
-

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

-
-
-
- -
-
- - - -
-
-
- -
-
-
- -
-
-
-
-

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

- -@section Scripts { - @await Html.PartialAsync("_ValidationScriptsPartial") -} \ No newline at end of file diff --git a/src/Dnn.vNext/Pages/Account/LoginWith2fa.cshtml.cs b/src/Dnn.vNext/Pages/Account/LoginWith2fa.cshtml.cs deleted file mode 100644 index 02d0dd2..0000000 --- a/src/Dnn.vNext/Pages/Account/LoginWith2fa.cshtml.cs +++ /dev/null @@ -1,95 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Identity; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; -using Microsoft.Extensions.Logging; -using Dnn.vNext.Data; - -namespace Dnn.vNext.Pages.Account -{ - public class LoginWith2faModel : PageModel - { - private readonly SignInManager _signInManager; - private readonly ILogger _logger; - - public LoginWith2faModel(SignInManager signInManager, ILogger logger) - { - _signInManager = signInManager; - _logger = logger; - } - - [BindProperty] - public InputModel Input { get; set; } - - public bool RememberMe { get; set; } - - public string ReturnUrl { get; set; } - - public class InputModel - { - [Required] - [StringLength(7, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", MinimumLength = 6)] - [DataType(DataType.Text)] - [Display(Name = "Authenticator code")] - public string TwoFactorCode { get; set; } - - [Display(Name = "Remember this machine")] - public bool RememberMachine { get; set; } - } - - public async Task OnGetAsync(bool rememberMe, string returnUrl = null) - { - // Ensure the user has gone through the username & password screen first - var user = await _signInManager.GetTwoFactorAuthenticationUserAsync(); - - if (user == null) - { - throw new ApplicationException($"Unable to load two-factor authentication user."); - } - - ReturnUrl = returnUrl; - RememberMe = rememberMe; - - return Page(); - } - - public async Task OnPostAsync(bool rememberMe, string returnUrl = null) - { - if (!ModelState.IsValid) - { - return Page(); - } - - var user = await _signInManager.GetTwoFactorAuthenticationUserAsync(); - if (user == null) - { - throw new ApplicationException($"Unable to load two-factor authentication user."); - } - - var authenticatorCode = Input.TwoFactorCode.Replace(" ", string.Empty).Replace("-", string.Empty); - - var result = await _signInManager.TwoFactorAuthenticatorSignInAsync(authenticatorCode, rememberMe, Input.RememberMachine); - - if (result.Succeeded) - { - _logger.LogInformation("User with ID '{UserId}' logged in with 2fa.", user.Id); - return LocalRedirect(Url.GetLocalUrl(returnUrl)); - } - else if (result.IsLockedOut) - { - _logger.LogWarning("User with ID '{UserId}' account locked out.", user.Id); - return RedirectToPage("./Lockout"); - } - else - { - _logger.LogWarning("Invalid authenticator code entered for user with ID '{UserId}'.", user.Id); - ModelState.AddModelError(string.Empty, "Invalid authenticator code."); - return Page(); - } - } - } -} diff --git a/src/Dnn.vNext/Pages/Account/LoginWithRecoveryCode.cshtml b/src/Dnn.vNext/Pages/Account/LoginWithRecoveryCode.cshtml deleted file mode 100644 index 4b32c1d..0000000 --- a/src/Dnn.vNext/Pages/Account/LoginWithRecoveryCode.cshtml +++ /dev/null @@ -1,29 +0,0 @@ -@page -@model LoginWithRecoveryCodeModel -@{ - ViewData["Title"] = "Recovery code verification"; -} - -

@ViewData["Title"]

-
-

- You have requested to log in with a recovery code. This login will not be remembered until you provide - an authenticator app code at log in or disable 2FA and log in again. -

-
-
-
-
-
- - - -
- -
-
-
- - @section Scripts { - @await Html.PartialAsync("_ValidationScriptsPartial") -} \ No newline at end of file diff --git a/src/Dnn.vNext/Pages/Account/LoginWithRecoveryCode.cshtml.cs b/src/Dnn.vNext/Pages/Account/LoginWithRecoveryCode.cshtml.cs deleted file mode 100644 index 374cd33..0000000 --- a/src/Dnn.vNext/Pages/Account/LoginWithRecoveryCode.cshtml.cs +++ /dev/null @@ -1,88 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Identity; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; -using Microsoft.Extensions.Logging; -using Dnn.vNext.Data; - -namespace Dnn.vNext.Pages.Account -{ - public class LoginWithRecoveryCodeModel : PageModel - { - private readonly SignInManager _signInManager; - private readonly ILogger _logger; - - public LoginWithRecoveryCodeModel(SignInManager signInManager, ILogger logger) - { - _signInManager = signInManager; - _logger = logger; - } - - [BindProperty] - public InputModel Input { get; set; } - - public string ReturnUrl { get; set; } - - public class InputModel - { - [BindProperty] - [Required] - [DataType(DataType.Text)] - [Display(Name = "Recovery Code")] - public string RecoveryCode { get; set; } - } - - public async Task OnGetAsync(string returnUrl = null) - { - // Ensure the user has gone through the username & password screen first - var user = await _signInManager.GetTwoFactorAuthenticationUserAsync(); - if (user == null) - { - throw new ApplicationException($"Unable to load two-factor authentication user."); - } - - ReturnUrl = returnUrl; - - return Page(); - } - - public async Task OnPostAsync(string returnUrl = null) - { - if (!ModelState.IsValid) - { - return Page(); - } - - var user = await _signInManager.GetTwoFactorAuthenticationUserAsync(); - if (user == null) - { - throw new ApplicationException($"Unable to load two-factor authentication user."); - } - - var recoveryCode = Input.RecoveryCode.Replace(" ", string.Empty); - - var result = await _signInManager.TwoFactorRecoveryCodeSignInAsync(recoveryCode); - - if (result.Succeeded) - { - _logger.LogInformation("User with ID '{UserId}' logged in with a recovery code.", user.Id); - return LocalRedirect(Url.GetLocalUrl(returnUrl)); - } - if (result.IsLockedOut) - { - _logger.LogWarning("User with ID '{UserId}' account locked out.", user.Id); - return RedirectToPage("./Lockout"); - } - else - { - _logger.LogWarning("Invalid recovery code entered for user with ID '{UserId}' ", user.Id); - ModelState.AddModelError(string.Empty, "Invalid recovery code entered."); - return Page(); - } - } - } -} diff --git a/src/Dnn.vNext/Pages/Account/Manage/ChangePassword.cshtml b/src/Dnn.vNext/Pages/Account/Manage/ChangePassword.cshtml deleted file mode 100644 index 6aa4723..0000000 --- a/src/Dnn.vNext/Pages/Account/Manage/ChangePassword.cshtml +++ /dev/null @@ -1,35 +0,0 @@ -@page -@model ChangePasswordModel -@{ - ViewData["Title"] = "Change password"; -} - -

@ViewData["Title"]

-@Html.Partial("_StatusMessage", Model.StatusMessage) -
-
-
-
-
- - - -
-
- - - -
-
- - - -
- -
-
-
- -@section Scripts { - @await Html.PartialAsync("_ValidationScriptsPartial") -} diff --git a/src/Dnn.vNext/Pages/Account/Manage/ChangePassword.cshtml.cs b/src/Dnn.vNext/Pages/Account/Manage/ChangePassword.cshtml.cs deleted file mode 100644 index 4dd8e99..0000000 --- a/src/Dnn.vNext/Pages/Account/Manage/ChangePassword.cshtml.cs +++ /dev/null @@ -1,102 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Identity; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; -using Microsoft.Extensions.Logging; -using Dnn.vNext.Data; - -namespace Dnn.vNext.Pages.Account.Manage -{ - public class ChangePasswordModel : PageModel - { - private readonly UserManager _userManager; - private readonly SignInManager _signInManager; - private readonly ILogger _logger; - - public ChangePasswordModel( - UserManager userManager, - SignInManager signInManager, - ILogger logger) - { - _userManager = userManager; - _signInManager = signInManager; - _logger = logger; - } - - [BindProperty] - public InputModel Input { get; set; } - - [TempData] - public string StatusMessage { get; set; } - - public class InputModel - { - [Required] - [DataType(DataType.Password)] - [Display(Name = "Current password")] - public string OldPassword { get; set; } - - [Required] - [StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", MinimumLength = 6)] - [DataType(DataType.Password)] - [Display(Name = "New password")] - public string NewPassword { get; set; } - - [DataType(DataType.Password)] - [Display(Name = "Confirm new password")] - [Compare("NewPassword", ErrorMessage = "The new password and confirmation password do not match.")] - public string ConfirmPassword { get; set; } - } - - public async Task OnGetAsync() - { - var user = await _userManager.GetUserAsync(User); - if (user == null) - { - throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); - } - - var hasPassword = await _userManager.HasPasswordAsync(user); - if (!hasPassword) - { - return RedirectToPage("./SetPassword"); - } - - return Page(); - } - - public async Task OnPostAsync() - { - if (!ModelState.IsValid) - { - return Page(); - } - - var user = await _userManager.GetUserAsync(User); - if (user == null) - { - throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); - } - - var changePasswordResult = await _userManager.ChangePasswordAsync(user, Input.OldPassword, Input.NewPassword); - if (!changePasswordResult.Succeeded) - { - foreach (var error in changePasswordResult.Errors) - { - ModelState.AddModelError(string.Empty, error.Description); - } - return Page(); - } - - await _signInManager.SignInAsync(user, isPersistent: false); - _logger.LogInformation("User changed their password successfully."); - StatusMessage = "Your password has been changed."; - - return RedirectToPage(); - } - } -} diff --git a/src/Dnn.vNext/Pages/Account/Manage/Disable2fa.cshtml b/src/Dnn.vNext/Pages/Account/Manage/Disable2fa.cshtml deleted file mode 100644 index 954093e..0000000 --- a/src/Dnn.vNext/Pages/Account/Manage/Disable2fa.cshtml +++ /dev/null @@ -1,25 +0,0 @@ -@page -@model Disable2faModel -@{ - ViewData["Title"] = "Disable two-factor authentication (2FA)"; - ViewData["ActivePage"] = "TwoFactorAuthentication"; -} - -

@ViewData["Title"]

- - - -
-
- -
-
diff --git a/src/Dnn.vNext/Pages/Account/Manage/Disable2fa.cshtml.cs b/src/Dnn.vNext/Pages/Account/Manage/Disable2fa.cshtml.cs deleted file mode 100644 index 261c737..0000000 --- a/src/Dnn.vNext/Pages/Account/Manage/Disable2fa.cshtml.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Identity; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; -using Microsoft.Extensions.Logging; -using Dnn.vNext.Data; - -namespace Dnn.vNext.Pages.Account.Manage -{ - public class Disable2faModel : PageModel - { - private readonly UserManager _userManager; - private readonly ILogger _logger; - - public Disable2faModel( - UserManager userManager, - ILogger logger) - { - _userManager = userManager; - _logger = logger; - } - - public async Task OnGet() - { - var user = await _userManager.GetUserAsync(User); - if (user == null) - { - throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); - } - - if (!await _userManager.GetTwoFactorEnabledAsync(user)) - { - throw new ApplicationException($"Cannot disable 2FA for user with ID '{_userManager.GetUserId(User)}' as it's not currently enabled."); - } - - return Page(); - } - - public async Task OnPostAsync() - { - var user = await _userManager.GetUserAsync(User); - if (user == null) - { - throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); - } - - var disable2faResult = await _userManager.SetTwoFactorEnabledAsync(user, false); - if (!disable2faResult.Succeeded) - { - throw new ApplicationException($"Unexpected error occurred disabling 2FA for user with ID '{_userManager.GetUserId(User)}'."); - } - - _logger.LogInformation("User with ID '{UserId}' has disabled 2fa.", _userManager.GetUserId(User)); - - return RedirectToPage("./TwoFactorAuthentication"); - } - } -} \ No newline at end of file diff --git a/src/Dnn.vNext/Pages/Account/Manage/EnableAuthenticator.cshtml b/src/Dnn.vNext/Pages/Account/Manage/EnableAuthenticator.cshtml deleted file mode 100644 index 9d1113d..0000000 --- a/src/Dnn.vNext/Pages/Account/Manage/EnableAuthenticator.cshtml +++ /dev/null @@ -1,53 +0,0 @@ -@page -@model EnableAuthenticatorModel -@{ - ViewData["Title"] = "Configure authenticator app"; - ViewData["ActivePage"] = "TwoFactorAuthentication"; -} - -

@ViewData["Title"]

-
-

To use an authenticator app go through the following steps:

-
    -
  1. -

    - Download a two-factor authenticator app like Microsoft Authenticator for - Windows Phone, - Android and - iOS or - Google Authenticator for - Android and - iOS. -

    -
  2. -
  3. -

    Scan the QR Code or enter this key @Model.SharedKey into your two factor authenticator app. Spaces and casing do not matter.

    -
    To enable QR code generation please read our documentation.
    -
    -
    -
  4. -
  5. -

    - Once you have scanned the QR code or input the key above, your two factor authentication app will provide you - with a unique code. Enter the code in the confirmation box below. -

    -
    -
    -
    -
    - - - -
    - -
    -
    -
    -
    -
  6. -
-
- -@section Scripts { - @await Html.PartialAsync("_ValidationScriptsPartial") -} diff --git a/src/Dnn.vNext/Pages/Account/Manage/EnableAuthenticator.cshtml.cs b/src/Dnn.vNext/Pages/Account/Manage/EnableAuthenticator.cshtml.cs deleted file mode 100644 index ad71756..0000000 --- a/src/Dnn.vNext/Pages/Account/Manage/EnableAuthenticator.cshtml.cs +++ /dev/null @@ -1,139 +0,0 @@ -using System; -using System.ComponentModel; -using System.ComponentModel.DataAnnotations; -using System.Collections.Generic; -using System.Text; -using System.Text.Encodings.Web; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Identity; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; -using Microsoft.Extensions.Logging; -using Dnn.vNext.Data; - -namespace Dnn.vNext.Pages.Account.Manage -{ - public class EnableAuthenticatorModel : PageModel - { - private readonly UserManager _userManager; - private readonly ILogger _logger; - private readonly UrlEncoder _urlEncoder; - - private const string AuthenticatorUriFormat = "otpauth://totp/{0}:{1}?secret={2}&issuer={0}&digits=6"; - - public EnableAuthenticatorModel( - UserManager userManager, - ILogger logger, - UrlEncoder urlEncoder) - { - _userManager = userManager; - _logger = logger; - _urlEncoder = urlEncoder; - } - - public string SharedKey { get; set; } - - public string AuthenticatorUri { get; set; } - - [BindProperty] - public InputModel Input { get; set; } - - public class InputModel - { - [Required] - [StringLength(7, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", MinimumLength = 6)] - [DataType(DataType.Text)] - [Display(Name = "Verification Code")] - public string Code { get; set; } - } - - public async Task OnGetAsync() - { - var user = await _userManager.GetUserAsync(User); - if (user == null) - { - throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); - } - - await LoadSharedKeyAndQrCodeUriAsync(user); - - return Page(); - } - - public async Task OnPostAsync() - { - var user = await _userManager.GetUserAsync(User); - if (user == null) - { - throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); - } - - if (!ModelState.IsValid) - { - await LoadSharedKeyAndQrCodeUriAsync(user); - return Page(); - } - - // Strip spaces and hypens - var verificationCode = Input.Code.Replace(" ", string.Empty).Replace("-", string.Empty); - - var is2faTokenValid = await _userManager.VerifyTwoFactorTokenAsync( - user, _userManager.Options.Tokens.AuthenticatorTokenProvider, verificationCode); - - if (!is2faTokenValid) - { - ModelState.AddModelError("Input.Code", "Verification code is invalid."); - await LoadSharedKeyAndQrCodeUriAsync(user); - return Page(); - } - - await _userManager.SetTwoFactorEnabledAsync(user, true); - _logger.LogInformation("User with ID '{UserId}' has enabled 2FA with an authenticator app.", user.Id); - - var recoveryCodes = await _userManager.GenerateNewTwoFactorRecoveryCodesAsync(user, 10); - TempData["RecoveryCodes"] = recoveryCodes.ToArray(); - return RedirectToPage("./ShowRecoveryCodes"); - } - - private async Task LoadSharedKeyAndQrCodeUriAsync(ApplicationUser user) - { - // Load the authenticator key & QR code URI to display on the form - var unformattedKey = await _userManager.GetAuthenticatorKeyAsync(user); - if (string.IsNullOrEmpty(unformattedKey)) - { - await _userManager.ResetAuthenticatorKeyAsync(user); - unformattedKey = await _userManager.GetAuthenticatorKeyAsync(user); - } - - SharedKey = FormatKey(unformattedKey); - AuthenticatorUri = GenerateQrCodeUri(user.Email, unformattedKey); - } - - private string FormatKey(string unformattedKey) - { - var result = new StringBuilder(); - int currentPosition = 0; - while (currentPosition + 4 < unformattedKey.Length) - { - result.Append(unformattedKey.Substring(currentPosition, 4)).Append(" "); - currentPosition += 4; - } - if (currentPosition < unformattedKey.Length) - { - result.Append(unformattedKey.Substring(currentPosition)); - } - - return result.ToString().ToLowerInvariant(); - } - - private string GenerateQrCodeUri(string email, string unformattedKey) - { - return string.Format( - AuthenticatorUriFormat, - _urlEncoder.Encode("Dnn.vNext"), - _urlEncoder.Encode(email), - unformattedKey); - } - } -} diff --git a/src/Dnn.vNext/Pages/Account/Manage/ExternalLogins.cshtml b/src/Dnn.vNext/Pages/Account/Manage/ExternalLogins.cshtml deleted file mode 100644 index ccb66a6..0000000 --- a/src/Dnn.vNext/Pages/Account/Manage/ExternalLogins.cshtml +++ /dev/null @@ -1,52 +0,0 @@ -@page -@model ExternalLoginsModel -@{ - ViewData["Title"] = "Manage your external logins"; -} - -@Html.Partial("_StatusMessage", Model.StatusMessage) -@if (Model.CurrentLogins?.Count > 0) -{ -

Registered Logins

- - - @foreach (var login in Model.CurrentLogins) - { - - - - - } - -
@login.LoginProvider - @if (Model.ShowRemoveButton) - { -
-
- - - -
-
- } - else - { - @:   - } -
-} -@if (Model.OtherLogins?.Count > 0) -{ -

Add another service to log in.

-
-
-
-

- @foreach (var provider in Model.OtherLogins) - { - - } -

-
-
-} diff --git a/src/Dnn.vNext/Pages/Account/Manage/ExternalLogins.cshtml.cs b/src/Dnn.vNext/Pages/Account/Manage/ExternalLogins.cshtml.cs deleted file mode 100644 index e8a4b11..0000000 --- a/src/Dnn.vNext/Pages/Account/Manage/ExternalLogins.cshtml.cs +++ /dev/null @@ -1,108 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Authentication; -using Microsoft.AspNetCore.Identity; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; -using Dnn.vNext.Data; - -namespace Dnn.vNext.Pages.Account.Manage -{ - public class ExternalLoginsModel : PageModel - { - private readonly UserManager _userManager; - private readonly SignInManager _signInManager; - - public ExternalLoginsModel( - UserManager userManager, - SignInManager signInManager) - { - _userManager = userManager; - _signInManager = signInManager; - } - - public IList CurrentLogins { get; set; } - - public IList OtherLogins { get; set; } - - public bool ShowRemoveButton { get; set; } - - [TempData] - public string StatusMessage { get; set; } - - public async Task OnGetAsync() - { - var user = await _userManager.GetUserAsync(User); - if (user == null) - { - throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); - } - - CurrentLogins = await _userManager.GetLoginsAsync(user); - OtherLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()) - .Where(auth => CurrentLogins.All(ul => auth.Name != ul.LoginProvider)) - .ToList(); - ShowRemoveButton = user.PasswordHash != null || CurrentLogins.Count > 1; - return Page(); - } - - public async Task OnPostRemoveLoginAsync(string loginProvider, string providerKey) - { - var user = await _userManager.GetUserAsync(User); - if (user == null) - { - throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); - } - - var result = await _userManager.RemoveLoginAsync(user, loginProvider, providerKey); - if (!result.Succeeded) - { - throw new ApplicationException($"Unexpected error occurred removing external login for user with ID '{user.Id}'."); - } - - await _signInManager.SignInAsync(user, isPersistent: false); - StatusMessage = "The external login was removed."; - return RedirectToPage(); - } - - public async Task OnPostLinkLoginAsync(string provider) - { - // Clear the existing external cookie to ensure a clean login process - await HttpContext.SignOutAsync(IdentityConstants.ExternalScheme); - - // Request a redirect to the external login provider to link a login for the current user - var redirectUrl = Url.Page("./ExternalLogins", pageHandler: "LinkLoginCallback"); - var properties = _signInManager.ConfigureExternalAuthenticationProperties(provider, redirectUrl, _userManager.GetUserId(User)); - return new ChallengeResult(provider, properties); - } - - public async Task OnGetLinkLoginCallbackAsync() - { - var user = await _userManager.GetUserAsync(User); - if (user == null) - { - throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); - } - - var info = await _signInManager.GetExternalLoginInfoAsync(await _userManager.GetUserIdAsync(user)); - if (info == null) - { - throw new ApplicationException($"Unexpected error occurred loading external login info for user with ID '{user.Id}'."); - } - - var result = await _userManager.AddLoginAsync(user, info); - if (!result.Succeeded) - { - throw new ApplicationException($"Unexpected error occurred adding external login for user with ID '{user.Id}'."); - } - - // Clear the existing external cookie to ensure a clean login process - await HttpContext.SignOutAsync(IdentityConstants.ExternalScheme); - - StatusMessage = "The external login was added."; - return RedirectToPage(); - } - } -} diff --git a/src/Dnn.vNext/Pages/Account/Manage/GenerateRecoveryCodes.cshtml b/src/Dnn.vNext/Pages/Account/Manage/GenerateRecoveryCodes.cshtml deleted file mode 100644 index 3738b92..0000000 --- a/src/Dnn.vNext/Pages/Account/Manage/GenerateRecoveryCodes.cshtml +++ /dev/null @@ -1,27 +0,0 @@ -@page -@model GenerateRecoveryCodesModel -@{ - ViewData["Title"] = "Generate two-factor authentication (2FA) recovery codes"; - ViewData["ActivePage"] = "TwoFactorAuthentication"; -} - -

@ViewData["Title"]

- - -
-
- -
-
diff --git a/src/Dnn.vNext/Pages/Account/Manage/GenerateRecoveryCodes.cshtml.cs b/src/Dnn.vNext/Pages/Account/Manage/GenerateRecoveryCodes.cshtml.cs deleted file mode 100644 index 00ed9da..0000000 --- a/src/Dnn.vNext/Pages/Account/Manage/GenerateRecoveryCodes.cshtml.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Identity; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; -using Microsoft.Extensions.Logging; -using Dnn.vNext.Data; - -namespace Dnn.vNext.Pages.Account.Manage -{ - public class GenerateRecoveryCodesModel : PageModel - { - private readonly UserManager _userManager; - private readonly ILogger _logger; - - public GenerateRecoveryCodesModel( - UserManager userManager, - ILogger logger) - { - _userManager = userManager; - _logger = logger; - } - - public async Task OnGetAsync() - { - var user = await _userManager.GetUserAsync(User); - if (user == null) - { - throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); - } - - if (!user.TwoFactorEnabled) - { - throw new ApplicationException($"Cannot generate recovery codes for user with ID '{user.Id}' because they do not have 2FA enabled."); - } - - return Page(); - } - - public async Task OnPostAsync() - { - var user = await _userManager.GetUserAsync(User); - if (user == null) - { - throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); - } - - if (!user.TwoFactorEnabled) - { - throw new ApplicationException($"Cannot generate recovery codes for user with ID '{user.Id}' as they do not have 2FA enabled."); - } - - var recoveryCodes = await _userManager.GenerateNewTwoFactorRecoveryCodesAsync(user, 10); - TempData["RecoveryCodes"] = recoveryCodes.ToArray(); - - _logger.LogInformation("User with ID '{UserId}' has generated new 2FA recovery codes.", user.Id); - - return RedirectToPage("./ShowRecoveryCodes"); - } - } -} \ No newline at end of file diff --git a/src/Dnn.vNext/Pages/Account/Manage/Index.cshtml b/src/Dnn.vNext/Pages/Account/Manage/Index.cshtml deleted file mode 100644 index 78a0383..0000000 --- a/src/Dnn.vNext/Pages/Account/Manage/Index.cshtml +++ /dev/null @@ -1,45 +0,0 @@ -@page -@model IndexModel -@{ - ViewData["Title"] = "Profile"; -} - -

@ViewData["Title"]

-@Html.Partial("_StatusMessage", Model.StatusMessage) -
-
-
-
-
- - -
-
- - @if (Model.IsEmailConfirmed) - { -
- - -
- } - else - { - - - } - -
-
- - - -
- -
-
-
- -@section Scripts { - @await Html.PartialAsync("_ValidationScriptsPartial") -} diff --git a/src/Dnn.vNext/Pages/Account/Manage/Index.cshtml.cs b/src/Dnn.vNext/Pages/Account/Manage/Index.cshtml.cs deleted file mode 100644 index b7ec201..0000000 --- a/src/Dnn.vNext/Pages/Account/Manage/Index.cshtml.cs +++ /dev/null @@ -1,128 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Linq; -using System.Text.Encodings.Web; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Identity; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; -using Dnn.vNext.Data; -using Dnn.vNext.Services; - -namespace Dnn.vNext.Pages.Account.Manage -{ - public partial class IndexModel : PageModel - { - private readonly UserManager _userManager; - private readonly SignInManager _signInManager; - private readonly IEmailSender _emailSender; - - public IndexModel( - UserManager userManager, - SignInManager signInManager, - IEmailSender emailSender) - { - _userManager = userManager; - _signInManager = signInManager; - _emailSender = emailSender; - } - - public string Username { get; set; } - - public bool IsEmailConfirmed { get; set; } - - [TempData] - public string StatusMessage { get; set; } - - [BindProperty] - public InputModel Input { get; set; } - - public class InputModel - { - [Required] - [EmailAddress] - public string Email { get; set; } - - [Phone] - [Display(Name = "Phone number")] - public string PhoneNumber { get; set; } - } - - public async Task OnGetAsync() - { - var user = await _userManager.GetUserAsync(User); - if (user == null) - { - throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); - } - - Username = user.UserName; - - Input = new InputModel - { - Email = user.Email, - PhoneNumber = user.PhoneNumber - }; - - IsEmailConfirmed = await _userManager.IsEmailConfirmedAsync(user); - - return Page(); - } - - public async Task OnPostAsync() - { - if (!ModelState.IsValid) - { - return Page(); - } - - var user = await _userManager.GetUserAsync(User); - if (user == null) - { - throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); - } - - if (Input.Email != user.Email) - { - var setEmailResult = await _userManager.SetEmailAsync(user, Input.Email); - if (!setEmailResult.Succeeded) - { - throw new ApplicationException($"Unexpected error occurred setting email for user with ID '{user.Id}'."); - } - } - - if (Input.PhoneNumber != user.PhoneNumber) - { - var setPhoneResult = await _userManager.SetPhoneNumberAsync(user, Input.PhoneNumber); - if (!setPhoneResult.Succeeded) - { - throw new ApplicationException($"Unexpected error occurred setting phone number for user with ID '{user.Id}'."); - } - } - - StatusMessage = "Your profile has been updated"; - return RedirectToPage(); - } - public async Task OnPostSendVerificationEmailAsync() - { - if (!ModelState.IsValid) - { - return Page(); - } - - var user = await _userManager.GetUserAsync(User); - if (user == null) - { - throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); - } - - var code = await _userManager.GenerateEmailConfirmationTokenAsync(user); - var callbackUrl = Url.EmailConfirmationLink(user.Id, code, Request.Scheme); - await _emailSender.SendEmailConfirmationAsync(user.Email, callbackUrl); - - StatusMessage = "Verification email sent. Please check your email."; - return RedirectToPage(); - } - } -} diff --git a/src/Dnn.vNext/Pages/Account/Manage/ManageNavPages.cs b/src/Dnn.vNext/Pages/Account/Manage/ManageNavPages.cs deleted file mode 100644 index e9c5da6..0000000 --- a/src/Dnn.vNext/Pages/Account/Manage/ManageNavPages.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc.Rendering; - -namespace Dnn.vNext.Pages.Account.Manage -{ - public static class ManageNavPages - { - public static string Index => "Index"; - - public static string ChangePassword => "ChangePassword"; - - public static string ExternalLogins => "ExternalLogins"; - - public static string TwoFactorAuthentication => "TwoFactorAuthentication"; - - public static string IndexNavClass(ViewContext viewContext) => PageNavClass(viewContext, Index); - - public static string ChangePasswordNavClass(ViewContext viewContext) => PageNavClass(viewContext, ChangePassword); - - public static string ExternalLoginsNavClass(ViewContext viewContext) => PageNavClass(viewContext, ExternalLogins); - - public static string TwoFactorAuthenticationNavClass(ViewContext viewContext) => PageNavClass(viewContext, TwoFactorAuthentication); - - public static string PageNavClass(ViewContext viewContext, string page) - { - var activePage = viewContext.ViewData["ActivePage"] as string - ?? System.IO.Path.GetFileNameWithoutExtension(viewContext.ActionDescriptor.DisplayName); - return string.Equals(activePage, page, StringComparison.OrdinalIgnoreCase) ? "active" : null; - } - } -} diff --git a/src/Dnn.vNext/Pages/Account/Manage/ResetAuthenticator.cshtml b/src/Dnn.vNext/Pages/Account/Manage/ResetAuthenticator.cshtml deleted file mode 100644 index a9534ae..0000000 --- a/src/Dnn.vNext/Pages/Account/Manage/ResetAuthenticator.cshtml +++ /dev/null @@ -1,23 +0,0 @@ -@page -@model ResetAuthenticatorModel -@{ - ViewData["Title"] = "Reset authenticator key"; - ViewData["ActivePage"] = "TwoFactorAuthentication"; -} - -

@ViewData["Title"]

- -
-
- -
-
\ No newline at end of file diff --git a/src/Dnn.vNext/Pages/Account/Manage/ResetAuthenticator.cshtml.cs b/src/Dnn.vNext/Pages/Account/Manage/ResetAuthenticator.cshtml.cs deleted file mode 100644 index ef742ab..0000000 --- a/src/Dnn.vNext/Pages/Account/Manage/ResetAuthenticator.cshtml.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Identity; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; -using Microsoft.Extensions.Logging; -using Dnn.vNext.Data; - -namespace Dnn.vNext.Pages.Account.Manage -{ - public class ResetAuthenticatorModel : PageModel - { - UserManager _userManager; - ILogger _logger; - - public ResetAuthenticatorModel( - UserManager userManager, - ILogger logger) - { - _userManager = userManager; - _logger = logger; - } - public async Task OnGet() - { - var user = await _userManager.GetUserAsync(User); - if (user == null) - { - throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); - } - - return Page(); - } - - public async Task OnPostAsync() - { - var user = await _userManager.GetUserAsync(User); - if (user == null) - { - throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); - } - - await _userManager.SetTwoFactorEnabledAsync(user, false); - await _userManager.ResetAuthenticatorKeyAsync(user); - _logger.LogInformation("User with ID '{UserId}' has reset their authentication app key.", user.Id); - - return RedirectToPage("./EnableAuthenticator"); - } - } -} \ No newline at end of file diff --git a/src/Dnn.vNext/Pages/Account/Manage/SetPassword.cshtml b/src/Dnn.vNext/Pages/Account/Manage/SetPassword.cshtml deleted file mode 100644 index 3f4544c..0000000 --- a/src/Dnn.vNext/Pages/Account/Manage/SetPassword.cshtml +++ /dev/null @@ -1,35 +0,0 @@ -@page -@model SetPasswordModel -@{ - ViewData["Title"] = "Set password"; - ViewData["ActivePage"] = "ChangePassword"; -} - -

Set your password

-@Html.Partial("_StatusMessage", Model.StatusMessage) -

- You do not have a local username/password for this site. Add a local - account so you can log in without an external login. -

-
-
-
-
-
- - - -
-
- - - -
- -
-
-
- -@section Scripts { - @await Html.PartialAsync("_ValidationScriptsPartial") -} diff --git a/src/Dnn.vNext/Pages/Account/Manage/SetPassword.cshtml.cs b/src/Dnn.vNext/Pages/Account/Manage/SetPassword.cshtml.cs deleted file mode 100644 index 8018ae3..0000000 --- a/src/Dnn.vNext/Pages/Account/Manage/SetPassword.cshtml.cs +++ /dev/null @@ -1,93 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Identity; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; -using Dnn.vNext.Data; - -namespace Dnn.vNext.Pages.Account.Manage -{ - public class SetPasswordModel : PageModel - { - private readonly UserManager _userManager; - private readonly SignInManager _signInManager; - - public SetPasswordModel( - UserManager userManager, - SignInManager signInManager) - { - _userManager = userManager; - _signInManager = signInManager; - } - - [BindProperty] - public InputModel Input { get; set; } - - [TempData] - public string StatusMessage { get; set; } - - public class InputModel - { - [Required] - [StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", MinimumLength = 6)] - [DataType(DataType.Password)] - [Display(Name = "New password")] - public string NewPassword { get; set; } - - [DataType(DataType.Password)] - [Display(Name = "Confirm new password")] - [Compare("NewPassword", ErrorMessage = "The new password and confirmation password do not match.")] - public string ConfirmPassword { get; set; } - } - - public async Task OnGetAsync() - { - var user = await _userManager.GetUserAsync(User); - if (user == null) - { - throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); - } - - var hasPassword = await _userManager.HasPasswordAsync(user); - - if (hasPassword) - { - return RedirectToPage("./ChangePassword"); - } - - return Page(); - } - - public async Task OnPostAsync() - { - if (!ModelState.IsValid) - { - return Page(); - } - - var user = await _userManager.GetUserAsync(User); - if (user == null) - { - throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); - } - - var addPasswordResult = await _userManager.AddPasswordAsync(user, Input.NewPassword); - if (!addPasswordResult.Succeeded) - { - foreach (var error in addPasswordResult.Errors) - { - ModelState.AddModelError(string.Empty, error.Description); - } - return Page(); - } - - await _signInManager.SignInAsync(user, isPersistent: false); - StatusMessage = "Your password has been set."; - - return RedirectToPage(); - } - } -} diff --git a/src/Dnn.vNext/Pages/Account/Manage/ShowRecoveryCodes.cshtml b/src/Dnn.vNext/Pages/Account/Manage/ShowRecoveryCodes.cshtml deleted file mode 100644 index a7225df..0000000 --- a/src/Dnn.vNext/Pages/Account/Manage/ShowRecoveryCodes.cshtml +++ /dev/null @@ -1,25 +0,0 @@ -@page -@model ShowRecoveryCodesModel -@{ - ViewData["Title"] = "Recovery codes"; - ViewData["ActivePage"] = "TwoFactorAuthentication"; -} - -

@ViewData["Title"]

- -
-
- @for (var row = 0; row < Model.RecoveryCodes.Length; row += 2) - { - @Model.RecoveryCodes[row] @Model.RecoveryCodes[row + 1]
- } -
-
\ No newline at end of file diff --git a/src/Dnn.vNext/Pages/Account/Manage/ShowRecoveryCodes.cshtml.cs b/src/Dnn.vNext/Pages/Account/Manage/ShowRecoveryCodes.cshtml.cs deleted file mode 100644 index 9d58254..0000000 --- a/src/Dnn.vNext/Pages/Account/Manage/ShowRecoveryCodes.cshtml.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; - -namespace Dnn.vNext.Pages.Account.Manage -{ - public class ShowRecoveryCodesModel : PageModel - { - public string[] RecoveryCodes { get; private set; } - - public IActionResult OnGet() - { - RecoveryCodes = (string[])TempData["RecoveryCodes"]; - if (RecoveryCodes == null) - { - return RedirectToPage("TwoFactorAuthentication"); - } - - return Page(); - } - } -} \ No newline at end of file diff --git a/src/Dnn.vNext/Pages/Account/Manage/TwoFactorAuthentication.cshtml b/src/Dnn.vNext/Pages/Account/Manage/TwoFactorAuthentication.cshtml deleted file mode 100644 index fabe199..0000000 --- a/src/Dnn.vNext/Pages/Account/Manage/TwoFactorAuthentication.cshtml +++ /dev/null @@ -1,49 +0,0 @@ -@page -@model TwoFactorAuthenticationModel -@{ - ViewData["Title"] = "Two-factor authentication (2FA)"; -} - -

@ViewData["Title"]

-@if (Model.Is2faEnabled) -{ - if (Model.RecoveryCodesLeft == 0) - { -
- You have no recovery codes left. -

You must generate a new set of recovery codes before you can log in with a recovery code.

-
- } - else if (Model.RecoveryCodesLeft == 1) - { -
- You have 1 recovery code left. -

You can generate a new set of recovery codes.

-
- } - else if (Model.RecoveryCodesLeft <= 3) - { -
- You have @Model.RecoveryCodesLeft recovery codes left. -

You should generate a new set of recovery codes.

-
- } - - Disable 2FA - Reset recovery codes -} - -
Authenticator app
-@if (!Model.HasAuthenticator) -{ - Add authenticator app -} -else -{ - Configure authenticator app - Reset authenticator app -} - -@section Scripts { - @await Html.PartialAsync("_ValidationScriptsPartial") -} diff --git a/src/Dnn.vNext/Pages/Account/Manage/TwoFactorAuthentication.cshtml.cs b/src/Dnn.vNext/Pages/Account/Manage/TwoFactorAuthentication.cshtml.cs deleted file mode 100644 index a4dbbfc..0000000 --- a/src/Dnn.vNext/Pages/Account/Manage/TwoFactorAuthentication.cshtml.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Identity; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; -using Microsoft.Extensions.Logging; -using Dnn.vNext.Data; - -namespace Dnn.vNext.Pages.Account.Manage -{ - public class TwoFactorAuthenticationModel : PageModel - { - private const string AuthenicatorUriFormat = "otpauth://totp/{0}:{1}?secret={2}&issuer={0}"; - - private readonly UserManager _userManager; - private readonly SignInManager _signInManager; - private readonly ILogger _logger; - - public TwoFactorAuthenticationModel( - UserManager userManager, - SignInManager signInManager, - ILogger logger) - { - _userManager = userManager; - _signInManager = signInManager; - _logger = logger; - } - - public bool HasAuthenticator { get; set; } - - public int RecoveryCodesLeft { get; set; } - - [BindProperty] - public bool Is2faEnabled { get; set; } - - public async Task OnGet() - { - var user = await _userManager.GetUserAsync(User); - if (user == null) - { - throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); - } - - HasAuthenticator = await _userManager.GetAuthenticatorKeyAsync(user) != null; - Is2faEnabled = await _userManager.GetTwoFactorEnabledAsync(user); - RecoveryCodesLeft = await _userManager.CountRecoveryCodesAsync(user); - - return Page(); - } - } -} \ No newline at end of file diff --git a/src/Dnn.vNext/Pages/Account/Manage/_Layout.cshtml b/src/Dnn.vNext/Pages/Account/Manage/_Layout.cshtml deleted file mode 100644 index c3f24b6..0000000 --- a/src/Dnn.vNext/Pages/Account/Manage/_Layout.cshtml +++ /dev/null @@ -1,23 +0,0 @@ -@{ - Layout = "/Pages/_Layout.cshtml"; -} - -

Manage your account

- -
-

Change your account settings

-
-
-
- @await Html.PartialAsync("_ManageNav") -
-
- @RenderBody() -
-
-
- -@section Scripts { - @RenderSection("Scripts", required: false) -} - diff --git a/src/Dnn.vNext/Pages/Account/Manage/_ManageNav.cshtml b/src/Dnn.vNext/Pages/Account/Manage/_ManageNav.cshtml deleted file mode 100644 index 16d50dd..0000000 --- a/src/Dnn.vNext/Pages/Account/Manage/_ManageNav.cshtml +++ /dev/null @@ -1,15 +0,0 @@ -@inject SignInManager SignInManager -@{ - var hasExternalLogins = (await SignInManager.GetExternalAuthenticationSchemesAsync()).Any(); -} - - - diff --git a/src/Dnn.vNext/Pages/Account/Manage/_StatusMessage.cshtml b/src/Dnn.vNext/Pages/Account/Manage/_StatusMessage.cshtml deleted file mode 100644 index e996841..0000000 --- a/src/Dnn.vNext/Pages/Account/Manage/_StatusMessage.cshtml +++ /dev/null @@ -1,10 +0,0 @@ -@model string - -@if (!String.IsNullOrEmpty(Model)) -{ - var statusMessageClass = Model.StartsWith("Error") ? "danger" : "success"; - -} diff --git a/src/Dnn.vNext/Pages/Account/Manage/_ViewImports.cshtml b/src/Dnn.vNext/Pages/Account/Manage/_ViewImports.cshtml deleted file mode 100644 index 2c6f1bc..0000000 --- a/src/Dnn.vNext/Pages/Account/Manage/_ViewImports.cshtml +++ /dev/null @@ -1 +0,0 @@ -@using Dnn.vNext.Pages.Account.Manage diff --git a/src/Dnn.vNext/Pages/Account/Register.cshtml b/src/Dnn.vNext/Pages/Account/Register.cshtml deleted file mode 100644 index 64f2151..0000000 --- a/src/Dnn.vNext/Pages/Account/Register.cshtml +++ /dev/null @@ -1,37 +0,0 @@ -@page -@model RegisterModel -@{ - ViewData["Title"] = "Register"; -} - -

@ViewData["Title"]

- -
-
-
-

Create a new account.

-
-
-
- - - -
-
- - - -
-
- - - -
- -
-
-
- -@section Scripts { - @await Html.PartialAsync("_ValidationScriptsPartial") -} diff --git a/src/Dnn.vNext/Pages/Account/Register.cshtml.cs b/src/Dnn.vNext/Pages/Account/Register.cshtml.cs deleted file mode 100644 index aa7b490..0000000 --- a/src/Dnn.vNext/Pages/Account/Register.cshtml.cs +++ /dev/null @@ -1,91 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Text.Encodings.Web; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Identity; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; -using Microsoft.Extensions.Logging; -using Dnn.vNext.Data; -using Dnn.vNext.Services; - -namespace Dnn.vNext.Pages.Account -{ - public class RegisterModel : PageModel - { - private readonly SignInManager _signInManager; - private readonly UserManager _userManager; - private readonly ILogger _logger; - private readonly IEmailSender _emailSender; - - public RegisterModel( - UserManager userManager, - SignInManager signInManager, - ILogger logger, - IEmailSender emailSender) - { - _userManager = userManager; - _signInManager = signInManager; - _logger = logger; - _emailSender = emailSender; - } - - [BindProperty] - public InputModel Input { get; set; } - - public string ReturnUrl { get; set; } - - public class InputModel - { - [Required] - [EmailAddress] - [Display(Name = "Email")] - public string Email { get; set; } - - [Required] - [StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", MinimumLength = 6)] - [DataType(DataType.Password)] - [Display(Name = "Password")] - public string Password { get; set; } - - [DataType(DataType.Password)] - [Display(Name = "Confirm password")] - [Compare("Password", ErrorMessage = "The password and confirmation password do not match.")] - public string ConfirmPassword { get; set; } - } - - public void OnGet(string returnUrl = null) - { - ReturnUrl = returnUrl; - } - - public async Task OnPostAsync(string returnUrl = null) - { - ReturnUrl = returnUrl; - if (ModelState.IsValid) - { - var user = new ApplicationUser { UserName = Input.Email, Email = Input.Email }; - var result = await _userManager.CreateAsync(user, Input.Password); - if (result.Succeeded) - { - _logger.LogInformation("User created a new account with password."); - - var code = await _userManager.GenerateEmailConfirmationTokenAsync(user); - var callbackUrl = Url.EmailConfirmationLink(user.Id, code, Request.Scheme); - await _emailSender.SendEmailConfirmationAsync(Input.Email, callbackUrl); - - await _signInManager.SignInAsync(user, isPersistent: false); - return LocalRedirect(Url.GetLocalUrl(returnUrl)); - } - foreach (var error in result.Errors) - { - ModelState.AddModelError(string.Empty, error.Description); - } - } - - // If we got this far, something failed, redisplay form - return Page(); - } - } -} diff --git a/src/Dnn.vNext/Pages/Account/ResetPassword.cshtml b/src/Dnn.vNext/Pages/Account/ResetPassword.cshtml deleted file mode 100644 index 85a81b1..0000000 --- a/src/Dnn.vNext/Pages/Account/ResetPassword.cshtml +++ /dev/null @@ -1,37 +0,0 @@ -@page -@model ResetPasswordModel -@{ - ViewData["Title"] = "Reset password"; -} - -

@ViewData["Title"]

-

Reset your password.

-
-
-
-
-
- -
- - - -
-
- - - -
-
- - - -
- -
-
-
- -@section Scripts { - @await Html.PartialAsync("_ValidationScriptsPartial") -} diff --git a/src/Dnn.vNext/Pages/Account/ResetPassword.cshtml.cs b/src/Dnn.vNext/Pages/Account/ResetPassword.cshtml.cs deleted file mode 100644 index de0c42b..0000000 --- a/src/Dnn.vNext/Pages/Account/ResetPassword.cshtml.cs +++ /dev/null @@ -1,87 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Identity; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; -using Dnn.vNext.Data; - -namespace Dnn.vNext.Pages.Account -{ - public class ResetPasswordModel : PageModel - { - private readonly UserManager _userManager; - - public ResetPasswordModel(UserManager userManager) - { - _userManager = userManager; - } - - [BindProperty] - public InputModel Input { get; set; } - - public class InputModel - { - [Required] - [EmailAddress] - public string Email { get; set; } - - [Required] - [StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", MinimumLength = 6)] - [DataType(DataType.Password)] - public string Password { get; set; } - - [DataType(DataType.Password)] - [Display(Name = "Confirm password")] - [Compare("Password", ErrorMessage = "The password and confirmation password do not match.")] - public string ConfirmPassword { get; set; } - - public string Code { get; set; } - } - - public IActionResult OnGet(string code = null) - { - if (code == null) - { - throw new ApplicationException("A code must be supplied for password reset."); - } - else - { - Input = new InputModel - { - Code = code - }; - return Page(); - } - } - - public async Task OnPostAsync() - { - if (!ModelState.IsValid) - { - return Page(); - } - - var user = await _userManager.FindByEmailAsync(Input.Email); - if (user == null) - { - // Don't reveal that the user does not exist - return RedirectToPage("./ResetPasswordConfirmation"); - } - - var result = await _userManager.ResetPasswordAsync(user, Input.Code, Input.Password); - if (result.Succeeded) - { - return RedirectToPage("./ResetPasswordConfirmation"); - } - - foreach (var error in result.Errors) - { - ModelState.AddModelError(string.Empty, error.Description); - } - return Page(); - } - } -} diff --git a/src/Dnn.vNext/Pages/Account/ResetPasswordConfirmation.cshtml b/src/Dnn.vNext/Pages/Account/ResetPasswordConfirmation.cshtml deleted file mode 100644 index a9972d4..0000000 --- a/src/Dnn.vNext/Pages/Account/ResetPasswordConfirmation.cshtml +++ /dev/null @@ -1,10 +0,0 @@ -@page -@model ResetPasswordConfirmationModel -@{ - ViewData["Title"] = "Reset password confirmation"; -} - -

@ViewData["Title"]

-

- Your password has been reset. Please click here to log in. -

diff --git a/src/Dnn.vNext/Pages/Account/ResetPasswordConfirmation.cshtml.cs b/src/Dnn.vNext/Pages/Account/ResetPasswordConfirmation.cshtml.cs deleted file mode 100644 index d7e01ee..0000000 --- a/src/Dnn.vNext/Pages/Account/ResetPasswordConfirmation.cshtml.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc.RazorPages; - -namespace Dnn.vNext.Pages.Account -{ - public class ResetPasswordConfirmationModel : PageModel - { - public void OnGet() - { - - } - } -} diff --git a/src/Dnn.vNext/Pages/Account/SignedOut.cshtml b/src/Dnn.vNext/Pages/Account/SignedOut.cshtml deleted file mode 100644 index 66ee2c8..0000000 --- a/src/Dnn.vNext/Pages/Account/SignedOut.cshtml +++ /dev/null @@ -1,10 +0,0 @@ -@page -@model SignedOutModel -@{ - ViewData["Title"] = "Signed out"; -} - -

@ViewData["Title"]

-

- You have successfully signed out. -

diff --git a/src/Dnn.vNext/Pages/Account/SignedOut.cshtml.cs b/src/Dnn.vNext/Pages/Account/SignedOut.cshtml.cs deleted file mode 100644 index ec39e5f..0000000 --- a/src/Dnn.vNext/Pages/Account/SignedOut.cshtml.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; - -public class SignedOutModel : PageModel -{ - public IActionResult OnGet() - { - if (User.Identity.IsAuthenticated) - { - // Redirect to home page if the user is authenticated. - return RedirectToPage("/Index"); - } - - return Page(); - } -} \ No newline at end of file diff --git a/src/Dnn.vNext/Pages/Account/_ViewImports.cshtml b/src/Dnn.vNext/Pages/Account/_ViewImports.cshtml deleted file mode 100644 index 3c411df..0000000 --- a/src/Dnn.vNext/Pages/Account/_ViewImports.cshtml +++ /dev/null @@ -1 +0,0 @@ -@using Dnn.vNext.Pages.Account diff --git a/src/Dnn.vNext/Pages/Demo.cshtml b/src/Dnn.vNext/Pages/Demo.cshtml index acf87af..2bbd3aa 100644 --- a/src/Dnn.vNext/Pages/Demo.cshtml +++ b/src/Dnn.vNext/Pages/Demo.cshtml @@ -6,6 +6,10 @@

Dnn.vNext Demo

+
+ Demo +
+
@@ -13,3 +17,10 @@
+@section scripts{ + +} diff --git a/src/Dnn.vNext/Pages/_Layout.cshtml b/src/Dnn.vNext/Pages/_Layout.cshtml index f7eb9af..e8d3d7d 100644 --- a/src/Dnn.vNext/Pages/_Layout.cshtml +++ b/src/Dnn.vNext/Pages/_Layout.cshtml @@ -35,7 +35,6 @@
  • Contact
  • Demo
  • - @await Html.PartialAsync("_LoginPartial") @@ -50,6 +49,7 @@ + @@ -65,6 +65,7 @@ crossorigin="anonymous" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"> + diff --git a/src/Dnn.vNext/Pages/_LoginPartial.cshtml b/src/Dnn.vNext/Pages/_LoginPartial.cshtml deleted file mode 100644 index 712a5f9..0000000 --- a/src/Dnn.vNext/Pages/_LoginPartial.cshtml +++ /dev/null @@ -1,25 +0,0 @@ -@using Microsoft.AspNetCore.Identity -@using Dnn.vNext.Data -@inject SignInManager SignInManager -@inject UserManager UserManager - -@if (SignInManager.IsSignedIn(User)) -{ - -} -else -{ - -} diff --git a/src/Dnn.vNext/Pages/_ViewImports.cshtml b/src/Dnn.vNext/Pages/_ViewImports.cshtml index b3cbeac..96929de 100644 --- a/src/Dnn.vNext/Pages/_ViewImports.cshtml +++ b/src/Dnn.vNext/Pages/_ViewImports.cshtml @@ -1,5 +1,3 @@ -@using Microsoft.AspNetCore.Identity @using Dnn.vNext -@using Dnn.vNext.Data @namespace Dnn.vNext.Pages @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers diff --git a/src/Dnn.vNext/Services/EmailSender.cs b/src/Dnn.vNext/Services/EmailSender.cs deleted file mode 100644 index 64e8252..0000000 --- a/src/Dnn.vNext/Services/EmailSender.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace Dnn.vNext.Services -{ - // This class is used by the application to send email for account confirmation and password reset. - // For more details see https://go.microsoft.com/fwlink/?LinkID=532713 - public class EmailSender : IEmailSender - { - public Task SendEmailAsync(string email, string subject, string message) - { - return Task.CompletedTask; - } - } -} diff --git a/src/Dnn.vNext/Services/IEmailSender.cs b/src/Dnn.vNext/Services/IEmailSender.cs deleted file mode 100644 index 209276d..0000000 --- a/src/Dnn.vNext/Services/IEmailSender.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace Dnn.vNext.Services -{ - public interface IEmailSender - { - Task SendEmailAsync(string email, string subject, string message); - } -} diff --git a/src/Dnn.vNext/Startup.cs b/src/Dnn.vNext/Startup.cs index f9b8276..fa5a950 100644 --- a/src/Dnn.vNext/Startup.cs +++ b/src/Dnn.vNext/Startup.cs @@ -3,14 +3,9 @@ using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Identity; -using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Hosting; -using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using Dnn.vNext.Data; -using Dnn.vNext.Services; namespace Dnn.vNext { @@ -26,23 +21,7 @@ public Startup(IConfiguration configuration) // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddDbContext(options => - options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); - - services.AddIdentity() - .AddEntityFrameworkStores() - .AddDefaultTokenProviders(); - - services.AddMvc() - .AddRazorPagesOptions(options => - { - options.Conventions.AuthorizeFolder("/Account/Manage"); - options.Conventions.AuthorizePage("/Account/Logout"); - }); - - // Register no-op EmailSender used by account confirmation and password reset during development - // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=532713 - services.AddSingleton(); + services.AddMvc(); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. @@ -52,7 +31,6 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env) { app.UseBrowserLink(); app.UseDeveloperExceptionPage(); - app.UseDatabaseErrorPage(); } else { @@ -61,8 +39,6 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env) app.UseStaticFiles(); - app.UseAuthentication(); - app.UseMvc(); } } diff --git a/src/Dnn.vNext/appsettings.json b/src/Dnn.vNext/appsettings.json index b16633a..5fff67b 100644 --- a/src/Dnn.vNext/appsettings.json +++ b/src/Dnn.vNext/appsettings.json @@ -1,7 +1,4 @@ { - "ConnectionStrings": { - "DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=aspnet-Dnn.vNext-53bc9b9d-9d6a-45d4-8429-2a2761773502;Trusted_Connection=True;MultipleActiveResultSets=true" - }, "Logging": { "IncludeScopes": false, "LogLevel": { diff --git a/src/Dnn.vNext/wwwroot/css/site.css b/src/Dnn.vNext/wwwroot/css/site.css index 48535e1..f8f10d3 100644 --- a/src/Dnn.vNext/wwwroot/css/site.css +++ b/src/Dnn.vNext/wwwroot/css/site.css @@ -39,3 +39,10 @@ body { border:gray dotted; margin:1em; } + +.new-module { + height: 150px; + width: 150px; + background-color:#c8c8c8; + border: gray solid; +} \ No newline at end of file