Register and Login possible

pull/1/head
DJh2o2 2023-01-18 09:08:50 +07:00
parent eb855ca5d6
commit 2bc970ad13
31 changed files with 325 additions and 997 deletions

@ -15,14 +15,11 @@ namespace Gremlin_BlazorServer.Areas.Identity.Pages.Account
private readonly UserManager<IdentityUser> _userManager;
private readonly ILogger<LoginWith2faModel> _logger;
public LoginWith2faModel(
SignInManager<IdentityUser> signInManager,
UserManager<IdentityUser> userManager,
ILogger<LoginWith2faModel> logger)
public LoginWith2faModel(SignInManager<IdentityUser> signInManager, UserManager<IdentityUser> userManager, ILogger<LoginWith2faModel> logger)
{
_signInManager = signInManager;
_userManager = userManager;
_logger = logger;
_userManager = userManager;
_logger = logger;
}
/// <summary>
@ -71,13 +68,7 @@ namespace Gremlin_BlazorServer.Areas.Identity.Pages.Account
public async Task<IActionResult> OnGetAsync(bool rememberMe, string returnUrl = null)
{
// Ensure the user has gone through the username & password screen first
IdentityUser user = await _signInManager.GetTwoFactorAuthenticationUserAsync();
if (user == null)
{
throw new InvalidOperationException($"Unable to load two-factor authentication user.");
}
_ = await _signInManager.GetTwoFactorAuthenticationUserAsync() ?? throw new InvalidOperationException($"Unable to load two-factor authentication user.");
ReturnUrl = returnUrl;
RememberMe = rememberMe;
@ -86,19 +77,11 @@ namespace Gremlin_BlazorServer.Areas.Identity.Pages.Account
public async Task<IActionResult> OnPostAsync(bool rememberMe, string returnUrl = null)
{
if (!ModelState.IsValid)
{
return Page();
}
if (!ModelState.IsValid) { return Page(); }
returnUrl ??= Url.Content("~/");
IdentityUser user = await _signInManager.GetTwoFactorAuthenticationUserAsync();
if (user == null)
{
throw new InvalidOperationException($"Unable to load two-factor authentication user.");
}
IdentityUser user = await _signInManager.GetTwoFactorAuthenticationUserAsync() ?? throw new InvalidOperationException($"Unable to load two-factor authentication user.");
string authenticatorCode = Input.TwoFactorCode.Replace(" ", string.Empty).Replace("-", string.Empty);
Microsoft.AspNetCore.Identity.SignInResult result = await _signInManager.TwoFactorAuthenticatorSignInAsync(authenticatorCode, rememberMe, Input.RememberMachine);

@ -1,10 +1,10 @@
@using Microsoft.AspNetCore.Identity
@inject SignInManager<IdentityUser> SignInManager
@inject UserManager<IdentityUser> UserManager
@inject SignInManager<IdentityUser> signInManager
@*@inject UserManager<IdentityUser> userManager*@
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
<ul class="navbar-nav">
@if (SignInManager.IsSignedIn(User))
@if (signInManager.IsSignedIn(User))
{
<li class="nav-item">
<a class="nav-link text-dark" asp-area="Identity" asp-page="/Account/Manage/Index" title="Manage">Hello @User.Identity?.Name!</a>

@ -36,10 +36,10 @@
public DateTime DataModificationDate { get; set; } = DateTime.Now;
public DateTime DataValidFrom { get; set; } = DateTime.Now;
public DateTime DataValidUntil { get; set; } = DateTime.MaxValue;
public string DataModificationByUser { get; set; } = "Gremlin";
public string DataModificationByUser { get; set; } = "Gremlin_BlazorServer";
public uint DataVersionNumber { get; set; }
public string? DataVersionComment { get; set; }
public string? DataStatus { get; set; }
public string DataStatus { get; set; } = "Active";
//IBase
//tbd

@ -20,9 +20,9 @@ namespace Gremlin_BlazorServer.Data.EntityClasses
public DateTime DataModificationDate { get; set; } = DateTime.Now;
public DateTime DataValidFrom { get; set; } = DateTime.Now;
public DateTime DataValidUntil { get; set; } = DateTime.MaxValue;
public string? DataModificationByUser { get; set; }
public string DataModificationByUser { get; set; } = "Gremlin_BlazorServer";
public uint DataVersionNumber { get; set; }
public string? DataVersionComment { get; set; }
public string? DataStatus { get; set; }
public string DataStatus { get; set; } = "Active";
}
}

@ -47,7 +47,7 @@
public DateTime DataModificationDate { get; set; } = DateTime.Now;
public DateTime DataValidFrom { get; set; } = DateTime.Now;
public DateTime DataValidUntil { get; set; } = DateTime.MaxValue;
public string? DataModificationByUser { get; set; }
public string DataModificationByUser { get; set; } = "Gremlin_BlazorServer";
public uint DataVersionNumber { get; set; }
public string? DataVersionComment { get; set; }
public string DataStatus { get; set; } = "Active";

@ -29,7 +29,7 @@
public DateTime DataModificationDate { get; set; } = DateTime.Now;
public DateTime DataValidFrom { get; set; } = DateTime.Now;
public DateTime DataValidUntil { get; set; } = DateTime.MaxValue;
public string? DataModificationByUser { get; set; }
public string DataModificationByUser { get; set; } = "Gremlin_BlazorServer";
public uint DataVersionNumber { get; set; }
public string? DataVersionComment { get; set; }
public string DataStatus { get; set; } = "Active";

@ -3,7 +3,7 @@
public interface IMetadata
{
DateTime DataCreationDate { get; set; }
string? DataModificationByUser { get; set; }
string DataModificationByUser { get; set; }
DateTime DataModificationDate { get; set; }
string DataStatus { get; set; }
DateTime DataValidFrom { get; set; }

@ -31,9 +31,9 @@
//metadata:
public DateTime DataCreationDate { get; set; } = DateTime.Now;
public string? DataModificationByUser { get; set; }
public string DataModificationByUser { get; set; } = "Gremlin_BlazorServer";
public DateTime DataModificationDate { get; set; } = DateTime.Now;
public string? DataStatus { get; set; }
public string DataStatus { get; set; } = "Active";
public DateTime DataValidFrom { get; set; } = DateTime.Now;
public DateTime DataValidUntil { get; set; } = DateTime.MaxValue;
public string? DataVersionComment { get; set; }

@ -31,7 +31,7 @@
public DateTime DataModificationDate { get; set; } = DateTime.Now;
public DateTime DataValidFrom { get; set; } = DateTime.Now;
public DateTime DataValidUntil { get; set; } = DateTime.MaxValue;
public string? DataModificationByUser { get; set; }
public string DataModificationByUser { get; set; } = "Gremlin_BlazorServer";
public uint DataVersionNumber { get; set; }
public string? DataVersionComment { get; set; }
public string DataStatus { get; set; } = "Active";

@ -20,9 +20,9 @@ namespace Gremlin_BlazorServer.Data.EntityClasses
public DateTime DataModificationDate { get; set; } = DateTime.Now;
public DateTime DataValidFrom { get; set; } = DateTime.Now;
public DateTime DataValidUntil { get; set; } = DateTime.MaxValue;
public string? DataModificationByUser { get; set; }
public string DataModificationByUser { get; set; } = "Gremlin_BlazorServer";
public uint DataVersionNumber { get; set; }
public string? DataVersionComment { get; set; }
public string? DataStatus { get; set; }
public string DataStatus { get; set; } = "Active";
}
}

@ -44,7 +44,7 @@
//metadata:
public DateTime DataCreationDate { get; set; } = DateTime.Now;
public string? DataModificationByUser { get; set; }
public string DataModificationByUser { get; set; } = "Gremlin_BlazorServer";
public DateTime DataModificationDate { get; set; } = DateTime.Now;
public string DataStatus { get; set; } = "Active";
public DateTime DataValidFrom { get; set; } = DateTime.Now;

@ -20,7 +20,7 @@
//metadata (subset of IMetadata)
public DateTime DataCreationDate { get; set; } = DateTime.Now;
public DateTime DataModificationDate { get; set; } = DateTime.Now;
public string DataModificationByUser { get; set; } = string.Empty;
public string DataModificationByUser { get; set; } = "Gremlin_BlazorServer";
protected virtual void Dispose(bool disposing)
{

@ -15,6 +15,6 @@
//metadata (subset of IMetadata)
public DateTime DataCreationDate { get; set; } = DateTime.Now;
public DateTime DataModificationDate { get; set; } = DateTime.Now;
public string? DataModificationByUser { get; set; }
public string DataModificationByUser { get; set; } = "Gremlin_BlazorServer";
}
}

@ -19,9 +19,9 @@ namespace Gremlin_BlazorServer.Data.EntityClasses
public DateTime DataModificationDate { get; set; } = DateTime.Now;
public DateTime DataValidFrom { get; set; } = DateTime.Now;
public DateTime DataValidUntil { get; set; } = DateTime.MaxValue;
public string? DataModificationByUser { get; set; }
public string DataModificationByUser { get; set; } = "Gremlin_BlazorServer";
public uint DataVersionNumber { get; set; }
public string? DataVersionComment { get; set; }
public string? DataStatus { get; set; }
public string DataStatus { get; set; } = "Active";
}
}

@ -6,6 +6,17 @@
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>a9d669d0-1af5-4bf8-912f-fb7ba89262fb</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<EnforceCodeStyleInBuild>False</EnforceCodeStyleInBuild>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<WarningsAsErrors />
<NoWarn />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<WarningsAsErrors />
<NoWarn />
</PropertyGroup>
<ItemGroup>
@ -13,6 +24,7 @@
<PackageReference Include="Blazorise.Components" Version="1.1.6" />
<PackageReference Include="Blazorise.DataGrid" Version="1.1.6" />
<PackageReference Include="Blazorise.Icons.FontAwesome" Version="1.1.6" />
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="7.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="7.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.2">
@ -26,7 +38,7 @@
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.17.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="7.0.2" />
<PackageReference Include="MySql.EntityFrameworkCore" Version="7.0.0-preview5" />
<PackageReference Include="MySql.EntityFrameworkCore" Version="7.0.0" />
<PackageReference Include="MySqlConnector" Version="2.3.0-beta.1" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="7.0.0" />
</ItemGroup>

@ -1,738 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace GremlinBlazorServer.Migrations
{
/// <inheritdoc />
public partial class InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
_ = migrationBuilder.DropIndex(
name: "UserNameIndex",
table: "AspNetUsers");
_ = migrationBuilder.DropIndex(
name: "RoleNameIndex",
table: "AspNetRoles");
_ = migrationBuilder.AlterColumn<string>(
name: "Value",
table: "AspNetUserTokens",
type: "longtext",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<string>(
name: "Name",
table: "AspNetUserTokens",
type: "varchar(128)",
maxLength: 128,
nullable: false,
oldClrType: typeof(string),
oldType: "nvarchar(128)",
oldMaxLength: 128)
.Annotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<string>(
name: "LoginProvider",
table: "AspNetUserTokens",
type: "varchar(128)",
maxLength: 128,
nullable: false,
oldClrType: typeof(string),
oldType: "nvarchar(128)",
oldMaxLength: 128)
.Annotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<string>(
name: "UserId",
table: "AspNetUserTokens",
type: "varchar(255)",
nullable: false,
oldClrType: typeof(string),
oldType: "nvarchar(450)")
.Annotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<string>(
name: "UserName",
table: "AspNetUsers",
type: "varchar(256)",
maxLength: 256,
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(256)",
oldMaxLength: 256,
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<bool>(
name: "TwoFactorEnabled",
table: "AspNetUsers",
type: "tinyint(1)",
nullable: false,
oldClrType: typeof(ulong),
oldType: "bit");
_ = migrationBuilder.AlterColumn<string>(
name: "SecurityStamp",
table: "AspNetUsers",
type: "longtext",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<bool>(
name: "PhoneNumberConfirmed",
table: "AspNetUsers",
type: "tinyint(1)",
nullable: false,
oldClrType: typeof(ulong),
oldType: "bit");
_ = migrationBuilder.AlterColumn<string>(
name: "PhoneNumber",
table: "AspNetUsers",
type: "longtext",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<string>(
name: "PasswordHash",
table: "AspNetUsers",
type: "longtext",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<string>(
name: "NormalizedUserName",
table: "AspNetUsers",
type: "varchar(256)",
maxLength: 256,
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(256)",
oldMaxLength: 256,
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<string>(
name: "NormalizedEmail",
table: "AspNetUsers",
type: "varchar(256)",
maxLength: 256,
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(256)",
oldMaxLength: 256,
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<DateTimeOffset>(
name: "LockoutEnd",
table: "AspNetUsers",
type: "datetime(6)",
nullable: true,
oldClrType: typeof(DateTimeOffset),
oldType: "datetimeoffset(6)",
oldNullable: true);
_ = migrationBuilder.AlterColumn<bool>(
name: "LockoutEnabled",
table: "AspNetUsers",
type: "tinyint(1)",
nullable: false,
oldClrType: typeof(ulong),
oldType: "bit");
_ = migrationBuilder.AlterColumn<bool>(
name: "EmailConfirmed",
table: "AspNetUsers",
type: "tinyint(1)",
nullable: false,
oldClrType: typeof(ulong),
oldType: "bit");
_ = migrationBuilder.AlterColumn<string>(
name: "Email",
table: "AspNetUsers",
type: "varchar(256)",
maxLength: 256,
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(256)",
oldMaxLength: 256,
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<string>(
name: "ConcurrencyStamp",
table: "AspNetUsers",
type: "longtext",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<string>(
name: "Id",
table: "AspNetUsers",
type: "varchar(255)",
nullable: false,
oldClrType: typeof(string),
oldType: "nvarchar(450)")
.Annotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<string>(
name: "RoleId",
table: "AspNetUserRoles",
type: "varchar(255)",
nullable: false,
oldClrType: typeof(string),
oldType: "nvarchar(450)")
.Annotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<string>(
name: "UserId",
table: "AspNetUserRoles",
type: "varchar(255)",
nullable: false,
oldClrType: typeof(string),
oldType: "nvarchar(450)")
.Annotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<string>(
name: "UserId",
table: "AspNetUserLogins",
type: "varchar(255)",
nullable: false,
oldClrType: typeof(string),
oldType: "nvarchar(450)")
.Annotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<string>(
name: "ProviderDisplayName",
table: "AspNetUserLogins",
type: "longtext",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<string>(
name: "ProviderKey",
table: "AspNetUserLogins",
type: "varchar(128)",
maxLength: 128,
nullable: false,
oldClrType: typeof(string),
oldType: "nvarchar(128)",
oldMaxLength: 128)
.Annotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<string>(
name: "LoginProvider",
table: "AspNetUserLogins",
type: "varchar(128)",
maxLength: 128,
nullable: false,
oldClrType: typeof(string),
oldType: "nvarchar(128)",
oldMaxLength: 128)
.Annotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<string>(
name: "UserId",
table: "AspNetUserClaims",
type: "varchar(255)",
nullable: false,
oldClrType: typeof(string),
oldType: "nvarchar(450)")
.Annotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<string>(
name: "ClaimValue",
table: "AspNetUserClaims",
type: "longtext",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<string>(
name: "ClaimType",
table: "AspNetUserClaims",
type: "longtext",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<string>(
name: "NormalizedName",
table: "AspNetRoles",
type: "varchar(256)",
maxLength: 256,
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(256)",
oldMaxLength: 256,
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<string>(
name: "Name",
table: "AspNetRoles",
type: "varchar(256)",
maxLength: 256,
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(256)",
oldMaxLength: 256,
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<string>(
name: "ConcurrencyStamp",
table: "AspNetRoles",
type: "longtext",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<string>(
name: "Id",
table: "AspNetRoles",
type: "varchar(255)",
nullable: false,
oldClrType: typeof(string),
oldType: "nvarchar(450)")
.Annotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<string>(
name: "RoleId",
table: "AspNetRoleClaims",
type: "varchar(255)",
nullable: false,
oldClrType: typeof(string),
oldType: "nvarchar(450)")
.Annotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<string>(
name: "ClaimValue",
table: "AspNetRoleClaims",
type: "longtext",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<string>(
name: "ClaimType",
table: "AspNetRoleClaims",
type: "longtext",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.CreateIndex(
name: "UserNameIndex",
table: "AspNetUsers",
column: "NormalizedUserName",
unique: true);
_ = migrationBuilder.CreateIndex(
name: "RoleNameIndex",
table: "AspNetRoles",
column: "NormalizedName",
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
_ = migrationBuilder.DropIndex(
name: "UserNameIndex",
table: "AspNetUsers");
_ = migrationBuilder.DropIndex(
name: "RoleNameIndex",
table: "AspNetRoles");
_ = migrationBuilder.AlterColumn<string>(
name: "Value",
table: "AspNetUserTokens",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true)
.OldAnnotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<string>(
name: "Name",
table: "AspNetUserTokens",
type: "nvarchar(128)",
maxLength: 128,
nullable: false,
oldClrType: typeof(string),
oldType: "varchar(128)",
oldMaxLength: 128)
.OldAnnotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<string>(
name: "LoginProvider",
table: "AspNetUserTokens",
type: "nvarchar(128)",
maxLength: 128,
nullable: false,
oldClrType: typeof(string),
oldType: "varchar(128)",
oldMaxLength: 128)
.OldAnnotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<string>(
name: "UserId",
table: "AspNetUserTokens",
type: "nvarchar(450)",
nullable: false,
oldClrType: typeof(string),
oldType: "varchar(255)")
.OldAnnotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<string>(
name: "UserName",
table: "AspNetUsers",
type: "nvarchar(256)",
maxLength: 256,
nullable: true,
oldClrType: typeof(string),
oldType: "varchar(256)",
oldMaxLength: 256,
oldNullable: true)
.OldAnnotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<ulong>(
name: "TwoFactorEnabled",
table: "AspNetUsers",
type: "bit",
nullable: false,
oldClrType: typeof(bool),
oldType: "tinyint(1)");
_ = migrationBuilder.AlterColumn<string>(
name: "SecurityStamp",
table: "AspNetUsers",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true)
.OldAnnotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<ulong>(
name: "PhoneNumberConfirmed",
table: "AspNetUsers",
type: "bit",
nullable: false,
oldClrType: typeof(bool),
oldType: "tinyint(1)");
_ = migrationBuilder.AlterColumn<string>(
name: "PhoneNumber",
table: "AspNetUsers",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true)
.OldAnnotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<string>(
name: "PasswordHash",
table: "AspNetUsers",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true)
.OldAnnotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<string>(
name: "NormalizedUserName",
table: "AspNetUsers",
type: "nvarchar(256)",
maxLength: 256,
nullable: true,
oldClrType: typeof(string),
oldType: "varchar(256)",
oldMaxLength: 256,
oldNullable: true)
.OldAnnotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<string>(
name: "NormalizedEmail",
table: "AspNetUsers",
type: "nvarchar(256)",
maxLength: 256,
nullable: true,
oldClrType: typeof(string),
oldType: "varchar(256)",
oldMaxLength: 256,
oldNullable: true)
.OldAnnotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<DateTimeOffset>(
name: "LockoutEnd",
table: "AspNetUsers",
type: "datetimeoffset(6)",
nullable: true,
oldClrType: typeof(DateTimeOffset),
oldType: "datetime(6)",
oldNullable: true);
_ = migrationBuilder.AlterColumn<ulong>(
name: "LockoutEnabled",
table: "AspNetUsers",
type: "bit",
nullable: false,
oldClrType: typeof(bool),
oldType: "tinyint(1)");
_ = migrationBuilder.AlterColumn<ulong>(
name: "EmailConfirmed",
table: "AspNetUsers",
type: "bit",
nullable: false,
oldClrType: typeof(bool),
oldType: "tinyint(1)");
_ = migrationBuilder.AlterColumn<string>(
name: "Email",
table: "AspNetUsers",
type: "nvarchar(256)",
maxLength: 256,
nullable: true,
oldClrType: typeof(string),
oldType: "varchar(256)",
oldMaxLength: 256,
oldNullable: true)
.OldAnnotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<string>(
name: "ConcurrencyStamp",
table: "AspNetUsers",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true)
.OldAnnotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<string>(
name: "Id",
table: "AspNetUsers",
type: "nvarchar(450)",
nullable: false,
oldClrType: typeof(string),
oldType: "varchar(255)")
.OldAnnotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<string>(
name: "RoleId",
table: "AspNetUserRoles",
type: "nvarchar(450)",
nullable: false,
oldClrType: typeof(string),
oldType: "varchar(255)")
.OldAnnotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<string>(
name: "UserId",
table: "AspNetUserRoles",
type: "nvarchar(450)",
nullable: false,
oldClrType: typeof(string),
oldType: "varchar(255)")
.OldAnnotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<string>(
name: "UserId",
table: "AspNetUserLogins",
type: "nvarchar(450)",
nullable: false,
oldClrType: typeof(string),
oldType: "varchar(255)")
.OldAnnotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<string>(
name: "ProviderDisplayName",
table: "AspNetUserLogins",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true)
.OldAnnotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<string>(
name: "ProviderKey",
table: "AspNetUserLogins",
type: "nvarchar(128)",
maxLength: 128,
nullable: false,
oldClrType: typeof(string),
oldType: "varchar(128)",
oldMaxLength: 128)
.OldAnnotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<string>(
name: "LoginProvider",
table: "AspNetUserLogins",
type: "nvarchar(128)",
maxLength: 128,
nullable: false,
oldClrType: typeof(string),
oldType: "varchar(128)",
oldMaxLength: 128)
.OldAnnotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<string>(
name: "UserId",
table: "AspNetUserClaims",
type: "nvarchar(450)",
nullable: false,
oldClrType: typeof(string),
oldType: "varchar(255)")
.OldAnnotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<string>(
name: "ClaimValue",
table: "AspNetUserClaims",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true)
.OldAnnotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<string>(
name: "ClaimType",
table: "AspNetUserClaims",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true)
.OldAnnotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<string>(
name: "NormalizedName",
table: "AspNetRoles",
type: "nvarchar(256)",
maxLength: 256,
nullable: true,
oldClrType: typeof(string),
oldType: "varchar(256)",
oldMaxLength: 256,
oldNullable: true)
.OldAnnotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<string>(
name: "Name",
table: "AspNetRoles",
type: "nvarchar(256)",
maxLength: 256,
nullable: true,
oldClrType: typeof(string),
oldType: "varchar(256)",
oldMaxLength: 256,
oldNullable: true)
.OldAnnotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<string>(
name: "ConcurrencyStamp",
table: "AspNetRoles",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true)
.OldAnnotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<string>(
name: "Id",
table: "AspNetRoles",
type: "nvarchar(450)",
nullable: false,
oldClrType: typeof(string),
oldType: "varchar(255)")
.OldAnnotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<string>(
name: "RoleId",
table: "AspNetRoleClaims",
type: "nvarchar(450)",
nullable: false,
oldClrType: typeof(string),
oldType: "varchar(255)")
.OldAnnotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<string>(
name: "ClaimValue",
table: "AspNetRoleClaims",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true)
.OldAnnotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.AlterColumn<string>(
name: "ClaimType",
table: "AspNetRoleClaims",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true)
.OldAnnotation("MySql:CharSet", "utf8mb4");
_ = migrationBuilder.CreateIndex(
name: "UserNameIndex",
table: "AspNetUsers",
column: "NormalizedUserName",
unique: true,
filter: "[NormalizedUserName] IS NOT NULL");
_ = migrationBuilder.CreateIndex(
name: "RoleNameIndex",
table: "AspNetRoles",
column: "NormalizedName",
unique: true,
filter: "[NormalizedName] IS NOT NULL");
}
}
}

@ -8,10 +8,10 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace GremlinBlazorServer.Migrations
namespace Gremlin_BlazorServer.Migrations
{
[DbContext(typeof(BlazorAuthDb))]
[Migration("20230117163307_InitialCreate")]
[Migration("20230118080017_InitialCreate")]
partial class InitialCreate
{
/// <inheritdoc />

@ -0,0 +1,262 @@
using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Gremlin_BlazorServer.Migrations
{
/// <inheritdoc />
public partial class InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterDatabase()
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "AspNetRoles",
columns: table => new
{
Id = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Name = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
NormalizedName = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
ConcurrencyStamp = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetRoles", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "AspNetUsers",
columns: table => new
{
Id = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
UserName = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
NormalizedUserName = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
Email = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
NormalizedEmail = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
EmailConfirmed = table.Column<bool>(type: "tinyint(1)", nullable: false),
PasswordHash = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
SecurityStamp = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
ConcurrencyStamp = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
PhoneNumber = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
PhoneNumberConfirmed = table.Column<bool>(type: "tinyint(1)", nullable: false),
TwoFactorEnabled = table.Column<bool>(type: "tinyint(1)", nullable: false),
LockoutEnd = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: true),
LockoutEnabled = table.Column<bool>(type: "tinyint(1)", nullable: false),
AccessFailedCount = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUsers", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "AspNetRoleClaims",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
RoleId = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
ClaimType = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
ClaimValue = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
},
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);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "AspNetUserClaims",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
UserId = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
ClaimType = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
ClaimValue = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
},
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);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "AspNetUserLogins",
columns: table => new
{
LoginProvider = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
ProviderKey = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
ProviderDisplayName = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
UserId = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4")
},
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);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "AspNetUserRoles",
columns: table => new
{
UserId = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
RoleId = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4")
},
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);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "AspNetUserTokens",
columns: table => new
{
UserId = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
LoginProvider = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Name = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Value = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name });
table.ForeignKey(
name: "FK_AspNetUserTokens_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_AspNetRoleClaims_RoleId",
table: "AspNetRoleClaims",
column: "RoleId");
migrationBuilder.CreateIndex(
name: "RoleNameIndex",
table: "AspNetRoles",
column: "NormalizedName",
unique: true);
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: "EmailIndex",
table: "AspNetUsers",
column: "NormalizedEmail");
migrationBuilder.CreateIndex(
name: "UserNameIndex",
table: "AspNetUsers",
column: "NormalizedUserName",
unique: true);
}
/// <inheritdoc />
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");
}
}
}

@ -1,37 +0,0 @@
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[AspNetUsers] (
[Id] NVARCHAR (450) NOT NULL,
[UserName] NVARCHAR (256) NULL,
[NormalizedUserName] NVARCHAR (256) NULL,
[Email] NVARCHAR (256) NULL,
[NormalizedEmail] NVARCHAR (256) NULL,
[EmailConfirmed] BIT NOT NULL,
[PasswordHash] NVARCHAR (MAX) NULL,
[SecurityStamp] NVARCHAR (MAX) NULL,
[ConcurrencyStamp] NVARCHAR (MAX) NULL,
[PhoneNumber] NVARCHAR (MAX) NULL,
[PhoneNumberConfirmed] BIT NOT NULL,
[TwoFactorEnabled] BIT NOT NULL,
[LockoutEnd] DATETIMEOFFSET (7) NULL,
[LockoutEnabled] BIT NOT NULL,
[AccessFailedCount] INT NOT NULL
);
GO
CREATE NONCLUSTERED INDEX [EmailIndex]
ON [dbo].[AspNetUsers]([NormalizedEmail] ASC);
GO
CREATE UNIQUE NONCLUSTERED INDEX [UserNameIndex]
ON [dbo].[AspNetUsers]([NormalizedUserName] ASC) WHERE ([NormalizedUserName] IS NOT NULL);
GO
ALTER TABLE [dbo].[AspNetUsers]
ADD CONSTRAINT [PK_AspNetUsers] PRIMARY KEY CLUSTERED ([Id] ASC);

@ -7,7 +7,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace GremlinBlazorServer.Migrations
namespace Gremlin_BlazorServer.Migrations
{
[DbContext(typeof(BlazorAuthDb))]
partial class BlazorAuthDbModelSnapshot : ModelSnapshot

@ -1 +0,0 @@
INSERT INTO [AspNetUsers] ([Id], [UserName], [NormalizedUserName], [Email], [NormalizedEmail], [EmailConfirmed], [PasswordHash], [SecurityStamp], [ConcurrencyStamp], [PhoneNumber], [PhoneNumberConfirmed], [TwoFactorEnabled], [LockoutEnd], [LockoutEnabled], [AccessFailedCount]) VALUES (N'44c5253a-52a1-4147-b280-7211d076e2eb', N'sascha@woitschetzki.de', N'SASCHA@WOITSCHETZKI.DE', N'sascha@woitschetzki.de', N'SASCHA@WOITSCHETZKI.DE', 1, N'AQAAAAIAAYagAAAAEMlw+bwiask31kpxmshQEXoBVbvZgGD3RyX9yvTdtKK4WCKqmLOBnGFbTcepUQabZw==', N'5TO5XR7JMXPUUPY2CZ44UGMO222CKAYP', N'9d8b8c88-5847-4449-af12-c5380aa9ae89', N'+4917622285334', 0, 1, NULL, 1, 0)

@ -1,37 +0,0 @@
CREATE TABLE IF NOT EXISTS `__EFMigrationsHistory` (
`MigrationId` varchar(150) CHARACTER SET utf8mb4 NOT NULL,
`ProductVersion` varchar(32) CHARACTER SET utf8mb4 NOT NULL,
CONSTRAINT `PK___EFMigrationsHistory` PRIMARY KEY (`MigrationId`)
) CHARACTER SET=utf8mb4;
START TRANSACTION;
CREATE TABLE IF NOT EXISTS `AspNetUsers`;
ALTER TABLE `AspNetUsers` DROP INDEX `UserNameIndex`;
CREATE TABLE IF NOT EXISTS `AspNetRoles`;
ALTER TABLE `AspNetRoles` DROP INDEX `RoleNameIndex`;
CREATE TABLE `AspNetUserTokens` (`Value` longtext CHARACTER SET utf8mb4 NULL, `Name` varchar(128) CHARACTER SET utf8mb4 NOT NULL, `LoginProvider` varchar(128) CHARACTER SET utf8mb4 NOT NULL, `UserId` varchar(255) CHARACTER SET utf8mb4 NOT NULL);
CREATE TABLE `AspNetUsers` (`UserName` varchar(256) CHARACTER SET utf8mb4 NULL,`TwoFactorEnabled` tinyint(1) NOT NULL,`SecurityStamp` longtext CHARACTER SET utf8mb4 NULL,`PhoneNumberConfirmed` tinyint(1) NOT NULL,`PhoneNumber` longtext CHARACTER SET utf8mb4 NULL,`PasswordHash` longtext CHARACTER SET utf8mb4 NULL,`NormalizedUserName` varchar(256) CHARACTER SET utf8mb4 NULL,`NormalizedEmail` varchar(256) CHARACTER SET utf8mb4 NULL,`LockoutEnd` datetime(6) NULL,`LockoutEnabled` tinyint(1) NOT NULL,`EmailConfirmed` tinyint(1) NOT NULL,`Email` varchar(256) CHARACTER SET utf8mb4 NULL,`ConcurrencyStamp` longtext CHARACTER SET utf8mb4 NULL,`Id` varchar(255) CHARACTER SET utf8mb4 NOT NULL);
CREATE TABLE `AspNetUserRoles` (`RoleId` varchar(255) CHARACTER SET utf8mb4 NOT NULL, `UserId` varchar(255) CHARACTER SET utf8mb4 NOT NULL);
CREATE TABLE `AspNetUserLogins` (`UserId` varchar(255) CHARACTER SET utf8mb4 NOT NULL, `ProviderDisplayName` longtext CHARACTER SET utf8mb4 NULL, `ProviderKey` varchar(128) CHARACTER SET utf8mb4 NOT NULL, `LoginProvider` varchar(128) CHARACTER SET utf8mb4 NOT NULL);
CREATE TABLE `AspNetUserClaims` (`UserId` varchar(255) CHARACTER SET utf8mb4 NOT NULL, `ClaimValue` longtext CHARACTER SET utf8mb4 NULL, `ClaimType` longtext CHARACTER SET utf8mb4 NULL);
CREATE TABLE `AspNetRoles` (`NormalizedName` varchar(256) CHARACTER SET utf8mb4 NULL,
`Name` varchar(256) CHARACTER SET utf8mb4 NULL,
`ConcurrencyStamp` longtext CHARACTER SET utf8mb4 NULL,
`Id` varchar(255) CHARACTER SET utf8mb4 NOT NULL);
CREATE TABLE `AspNetRoleClaims` (`RoleId` varchar(255) CHARACTER SET utf8mb4 NOT NULL, `ClaimValue` longtext CHARACTER SET utf8mb4 NULL, `ClaimType` longtext CHARACTER SET utf8mb4 NULL);
CREATE UNIQUE INDEX `UserNameIndex` ON `AspNetUsers` (`NormalizedUserName`);
CREATE UNIQUE INDEX `RoleNameIndex` ON `AspNetRoles` (`NormalizedName`);
INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`)
VALUES ('20230117163307_InitialCreate', '7.0.2');

@ -38,24 +38,25 @@
@code {
[CascadingParameter]
private Task<AuthenticationState> authenticationStateTask { get; set; }
private Task<AuthenticationState>? authenticationStateTask { get; set; }
private IList<Account> accounts;
private Account selectedAccount;
private IList<Account>? accounts;
private Account? selectedAccount;
protected override async Task OnInitializedAsync()
{
var user = (await authenticationStateTask).User;
if (user.Identity.IsAuthenticated)
if (authenticationStateTask != null)
{
accounts = GenericController.GetAll<Account>();
selectedAccount = accounts.First();
var user = (await authenticationStateTask).User;
if (user.Identity != null && user.Identity.IsAuthenticated)
{
accounts = GenericController.GetAll<Account>();
selectedAccount = accounts.First();
}
}
}
private async Task OnSelectedAccountChanged(Account sA)
{
selectedAccount = sA;
}
private void OnSelectedAccountChanged(Account sA) => selectedAccount = sA;
}

@ -1,27 +0,0 @@
@using Microsoft.AspNetCore.Identity
@inject SignInManager<IdentityUser> SignInManager
@inject UserManager<IdentityUser> UserManager
<ul class="navbar-nav">
@if (SignInManager.IsSignedIn(User))
{
<li class="nav-item">
<a id="manage" class="nav-link text-dark" asp-area="Identity" asp-page="/Account/Manage/Index" title="Manage">Hello @UserManager.GetUserName(User)!</a>
</li>
<li class="nav-item">
<form id="logoutForm" class="form-inline" asp-area="Identity" asp-page="/Account/Logout" asp-route-returnUrl="@Url.Page("/Index", new { area = "" })">
<button id="logout" type="submit" class="nav-link btn btn-link text-dark border-0">Logout</button>
</form>
</li>
}
else
{
<li class="nav-item">
<a class="nav-link text-dark" id="register" asp-area="Identity" asp-page="/Account/Register">Register</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" id="login" asp-area="Identity" asp-page="/Account/Login">Login</a>
</li>
}
</ul>

@ -1,18 +0,0 @@
<environment include="Development">
<script src="~/Identity/lib/jquery-validation/dist/jquery.validate.js"></script>
<script src="~/Identity/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js"></script>
</environment>
<environment exclude="Development">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.17.0/jquery.validate.min.js"
asp-fallback-src="~/Identity/lib/jquery-validation/dist/jquery.validate.min.js"
asp-fallback-test="window.jQuery && window.jQuery.validator"
crossorigin="anonymous"
integrity="sha384-rZfj/ogBloos6wzLGpPkkOr/gpkBNLZ6b6yLy4o+ok+t/SAKlL5mvXLr0OXNi1Hp">
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validation-unobtrusive/3.2.11/jquery.validate.unobtrusive.min.js"
asp-fallback-src="~/Identity/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"
asp-fallback-test="window.jQuery && window.jQuery.validator && window.jQuery.validator.unobtrusive"
crossorigin="anonymous"
integrity="sha384-R3vNCHsZ+A2Lo3d5A6XNP7fdQkeswQWTIPfiYwSpEP3YV079R+93YzTeZRah7f/F">
</script>
</environment>

@ -1,6 +0,0 @@
@using Microsoft.AspNetCore.Identity
@using Gremlin_BlazorServer.Areas.Identity
Gremlin_BlazorServer.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

@ -29,7 +29,6 @@ builder.Services.AddScoped<GenericTypeController<CustomDescription>>();
builder.Services.AddScoped<QuoteHandling>();
builder.Services.AddScoped<LineItemService>();
builder.Services.AddScoped<LoginService>();
builder.Services.AddScoped<ClipboardService>();
builder.Services.AddBlazorise(options => { options.Immediate = true; }).AddBootstrapProviders().AddFontAwesomeIcons();
@ -40,10 +39,10 @@ string connection = "server0";
string connectionString = builder.Configuration.GetConnectionString(connection) ?? throw new InvalidOperationException($"Connection string '{connection}' not found.");
ServerVersion serverVersion = ServerVersion.AutoDetect(connectionString);
builder.Services.AddDbContext<BlazorAuthDb>(options => options.UseMySql(connectionString, serverVersion));
//
builder.Services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = true).AddEntityFrameworkStores<BlazorAuthDb>();
builder.Services.AddScoped<AuthenticationStateProvider, RevalidatingIdentityAuthenticationStateProvider<IdentityUser>>();
builder.Services.AddControllersWithViews();
//
builder.WebHost.UseWebRoot("wwwroot");
builder.WebHost.UseStaticWebAssets();

@ -1,70 +0,0 @@
using Gremlin_BlazorServer.Data.DBClasses;
using Gremlin_BlazorServer.Data.EntityClasses;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.EntityFrameworkCore;
using System.Diagnostics;
namespace Gremlin_BlazorServer.Services;
public class LoginService
{
private readonly GremlinDb gremlinDb;
public LoginService(GremlinDb gC)
{
gremlinDb = gC;
}
private Task<AuthenticationState> AuthenticationStateTask { get; set; } = default!;
public void ConfigureServices(IServiceCollection services)
{
_ = services.AddDbContext<GremlinDb>(ServiceLifetime.Scoped);
}
public async Task<List<RegisteredUser>> GetAllRegisteredUserAsync()
{
return await gremlinDb.RegisteredUser.ToListAsync();
}
public async Task<bool> InsertRegisteredUserAsync(RegisteredUser registeredUser)
{
try
{
_ = await gremlinDb.RegisteredUser.AddAsync(registeredUser);
_ = await gremlinDb.SaveChangesAsync();
return true;
}
catch (Exception exception)
{
Debug.WriteLine(exception.Message);
return false;
}
}
private async Task<RegisteredUser?> GetRegisteredUserAsync(string registeredUserName)
{
return await gremlinDb.RegisteredUser.FirstOrDefaultAsync(rU => rU.UserName.Equals(registeredUserName));
}
public async Task<bool> UpdateRegisteredUserAsync(RegisteredUser registeredUser)
{
_ = gremlinDb.RegisteredUser.Update(registeredUser);
_ = await gremlinDb.SaveChangesAsync();
return true;
}
public async Task<bool> DeleteRegisteredUserAsync(RegisteredUser registeredUser)
{
_ = gremlinDb.Remove(registeredUser);
_ = await gremlinDb.SaveChangesAsync();
return true;
}
public async Task<bool> ValidateUserAsync(RegisteredUser registeredUser)
{
_ = await Task.Run(() => GetRegisteredUserAsync(registeredUser.UserName));
AuthenticationState authState = await AuthenticationStateTask;
return authState.User.Identity is { IsAuthenticated: true };
}
}

@ -17,7 +17,7 @@ namespace Gremlin_BlazorServer.Services
return new(correctedTex);
}
private StringBuilder CreateBriefkopf(Contact recipient, bool tex = false)
private static StringBuilder CreateBriefkopf(Contact recipient, bool tex = false)
{
StringBuilder briefkopf = new();

@ -0,0 +1,5 @@
{
"version": "1.0",
"defaultProvider": "cdnjs",
"libraries": []
}