Skip to content

Commit

Permalink
Small fix
Browse files Browse the repository at this point in the history
  • Loading branch information
TheDayIsMyEnemy committed Jul 24, 2024
1 parent 0f1cbd2 commit 9db6e64
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 63 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using MudBlazor;

namespace AdminDashboard.Themes
namespace AdminDashboard.Components
{
public class DarkTheme : MudTheme
{
Expand Down
2 changes: 1 addition & 1 deletion src/AdminDashboard/Components/Layout/MainLayout.razor
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
private bool _isDrawerOpen = true;
private bool _isDarkMode = false;
private MudThemeProvider _mudThemeProvider = null!;
private AdminDashboard.Themes.DarkTheme _theme = new AdminDashboard.Themes.DarkTheme();
private Components.DarkTheme _theme = new DarkTheme();

private void DrawerToggle() => _isDrawerOpen = !_isDrawerOpen;

Expand Down
7 changes: 4 additions & 3 deletions src/AdminDashboard/Identity/AppIdentityDbContextSeed.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;

namespace AdminDashboard.Identity
{
Expand All @@ -19,6 +18,8 @@ public static async Task Seed(
if (!roleManager.Roles.Any())
{
await roleManager.CreateAsync(new Role(Constants.AdminRole));

logger.LogInformation("Default administrator role created");
}

if (!userManager.Users.Any())
Expand All @@ -29,9 +30,9 @@ await CreateUser(
Constants.AdminRole,
userManager
);
}

logger.LogInformation("Default user created");
logger.LogInformation("Default user created");
}
}

private static async Task<User> CreateUser(
Expand Down
2 changes: 0 additions & 2 deletions src/AdminDashboard/Identity/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ namespace AdminDashboard.Identity
{
public static class Constants
{
public const int DefaultPropertyLength = 50;

public const string LoginPath = "/Account/Login";
public const string LogoutPath = "/Account/Logout";

Expand Down
16 changes: 2 additions & 14 deletions src/AdminDashboard/Identity/IdentityConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,6 @@ public static void ConfigureIdentity(this ModelBuilder builder)
.WithOne(e => e.User)
.HasForeignKey(ur => ur.UserId)
.IsRequired();
b.Property(u => u.Email).HasMaxLength(Constants.DefaultPropertyLength);
b.Property(u => u.NormalizedUserName).HasMaxLength(Constants.DefaultPropertyLength);
b.Property(u => u.UserName).HasMaxLength(Constants.DefaultPropertyLength);
b.Property(u => u.NormalizedUserName).HasMaxLength(Constants.DefaultPropertyLength);
b.Property(u => u.PhoneNumber).HasMaxLength(15);
// b.Property(e => e.AccountStatus)
// .HasMaxLength(50)
// .HasConversion(
// v => v.ToString(),
// v => (UserAccountStatus)Enum.Parse(typeof(UserAccountStatus), v))
// .IsUnicode(false);
});

builder.Entity<Role>(b =>
Expand All @@ -33,8 +21,8 @@ public static void ConfigureIdentity(this ModelBuilder builder)
.HasForeignKey(ur => ur.RoleId)
.IsRequired();
b.Property(r => r.Name).HasMaxLength(Constants.DefaultPropertyLength);
b.Property(r => r.NormalizedName).HasMaxLength(Constants.DefaultPropertyLength);
b.Property(r => r.Name).HasMaxLength(20);
b.Property(r => r.NormalizedName).HasMaxLength(20);
});
}
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace AdminDashboard.Identity.Migrations
{
/// <inheritdoc />
public partial class InitialIdentityModel : Migration
public partial class InitialIdentity : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
Expand All @@ -21,9 +21,9 @@ protected override void Up(MigrationBuilder migrationBuilder)
{
Id = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Name = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true)
Name = table.Column<string>(type: "varchar(24)", maxLength: 24, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
NormalizedName = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true)
NormalizedName = table.Column<string>(type: "varchar(24)", maxLength: 24, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
ConcurrencyStamp = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
Expand All @@ -41,11 +41,11 @@ protected override void Up(MigrationBuilder migrationBuilder)
Id = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
AccountStatus = table.Column<int>(type: "int", nullable: false),
UserName = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true)
UserName = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
NormalizedUserName = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true)
NormalizedUserName = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
Email = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true)
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"),
Expand All @@ -56,7 +56,7 @@ protected override void Up(MigrationBuilder migrationBuilder)
.Annotation("MySql:CharSet", "utf8mb4"),
ConcurrencyStamp = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
PhoneNumber = table.Column<string>(type: "varchar(15)", maxLength: 15, nullable: true)
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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.2")
.HasAnnotation("ProductVersion", "8.0.2")
.HasAnnotation("Relational:MaxIdentifierLength", 64);

modelBuilder.Entity("AdminDashboard.Identity.Role", b =>
Expand All @@ -29,12 +29,12 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.HasColumnType("longtext");
b.Property<string>("Name")
.HasMaxLength(50)
.HasColumnType("varchar(50)");
.HasMaxLength(24)
.HasColumnType("varchar(24)");
b.Property<string>("NormalizedName")
.HasMaxLength(50)
.HasColumnType("varchar(50)");
.HasMaxLength(24)
.HasColumnType("varchar(24)");
b.HasKey("Id");
Expand All @@ -61,8 +61,8 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.HasColumnType("longtext");
b.Property<string>("Email")
.HasMaxLength(50)
.HasColumnType("varchar(50)");
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<bool>("EmailConfirmed")
.HasColumnType("tinyint(1)");
Expand All @@ -78,15 +78,14 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.HasColumnType("varchar(256)");
b.Property<string>("NormalizedUserName")
.HasMaxLength(50)
.HasColumnType("varchar(50)");
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<string>("PasswordHash")
.HasColumnType("longtext");
b.Property<string>("PhoneNumber")
.HasMaxLength(15)
.HasColumnType("varchar(15)");
.HasColumnType("longtext");
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("tinyint(1)");
Expand All @@ -98,8 +97,8 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.HasColumnType("tinyint(1)");
b.Property<string>("UserName")
.HasMaxLength(50)
.HasColumnType("varchar(50)");
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.HasKey("Id");
Expand Down
9 changes: 4 additions & 5 deletions src/AdminDashboard/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,16 @@
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.EntityFrameworkCore;
using AdminDashboard.Components;
using AdminDashboard.Components.Account;
using AdminDashboard.Identity;
using AdminDashboard;

var builder = WebApplication.CreateBuilder(args);

builder.Host.UseSerilog((context, services, loggerConfig) =>
loggerConfig.ReadFrom.Configuration(context.Configuration));

// var dbConnectionString = builder.Configuration.GetConnectionString("BlazorTemplate");
var identityDbConnectionString = builder.Configuration.GetConnectionString("BlazorTemplate.Identity");
// var dbConnectionString = builder.Configuration.GetConnectionString("AdminDashboard");
var identityDbConnectionString = builder.Configuration.GetConnectionString("AdminDashboard.Identity");
// builder.Services.AddDbContextFactory<AppDbContext>(
// options =>
// options
Expand Down Expand Up @@ -90,7 +88,8 @@
app.UseStaticFiles();
app.UseAntiforgery();

app.MapRazorComponents<App>().AddInteractiveServerRenderMode();
app.MapRazorComponents<AdminDashboard.Components.App>()
.AddInteractiveServerRenderMode();

app.MapAdditionalIdentityEndpoints();

Expand Down
4 changes: 2 additions & 2 deletions src/AdminDashboard/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"ConnectionStrings": {
"BlazorTemplate": "server=localhost;port=1432;user=root;password=1234;database=BlazorTemplate",
"BlazorTemplate.Identity": "server=localhost;port=1432;user=root;password=1234;database=BlazorTemplate.Identity"
"AdminDashboard": "server=localhost;port=1432;user=root;password=1234;database=AdminDashboard",
"AdminDashboard.Identity": "server=localhost;port=1432;user=root;password=1234;database=AdminDashboard.Identity"
},
"DetailedErrors": true
}

0 comments on commit 9db6e64

Please sign in to comment.