From 8301418085ba404ef72d8555207d6df6abb348f5 Mon Sep 17 00:00:00 2001 From: jvyden Date: Sun, 22 May 2022 15:51:02 -0400 Subject: [PATCH] Use permission level model for permissions This is better. Because having 20 fucking columns for permissions is STUPID. --- .../Controllers/LoginController.cs | 2 +- .../Controllers/Admin/AdminUserController.cs | 3 +- .../Pages/Admin/AdminBanUserPage.cshtml.cs | 3 +- .../Pages/Admin/AdminPanelUsersPage.cshtml | 41 +- .../Pages/LoginForm.cshtml.cs | 2 +- .../Pages/UserPage.cshtml | 4 +- .../Pages/UsersPage.cshtml.cs | 5 +- .../Tests/AdminTests.cs | 5 +- .../Commands/MakeUserAdminCommand.cs | 2 +- .../Administration/PermissionLevel.cs | 9 + ProjectLighthouse/Helpers/StatisticsHelper.cs | 3 +- ...20220522192158_SwitchToPermissionLevels.cs | 56 ++ .../Migrations/DatabaseModelSnapshot.cs | 816 +++++++++--------- ProjectLighthouse/PlayerData/Profiles/User.cs | 18 +- ProjectLighthouse/ProjectLighthouse.csproj | 4 + scripts-and-tools/create-migration.sh | 2 +- 16 files changed, 542 insertions(+), 433 deletions(-) create mode 100644 ProjectLighthouse/Administration/PermissionLevel.cs create mode 100644 ProjectLighthouse/Migrations/20220522192158_SwitchToPermissionLevels.cs diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/LoginController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/LoginController.cs index 270aa145..11d6834e 100644 --- a/ProjectLighthouse.Servers.GameServer/Controllers/LoginController.cs +++ b/ProjectLighthouse.Servers.GameServer/Controllers/LoginController.cs @@ -74,7 +74,7 @@ public class LoginController : ControllerBase User? user = await this.database.UserFromGameToken(token, true); - if (user == null || user.Banned) + if (user == null || user.IsBanned) { Logger.Error($"Unable to find user {npTicket.Username} from token", LogArea.Login); return this.StatusCode(403, ""); diff --git a/ProjectLighthouse.Servers.Website/Controllers/Admin/AdminUserController.cs b/ProjectLighthouse.Servers.Website/Controllers/Admin/AdminUserController.cs index a0b0ee4c..72d8023d 100644 --- a/ProjectLighthouse.Servers.Website/Controllers/Admin/AdminUserController.cs +++ b/ProjectLighthouse.Servers.Website/Controllers/Admin/AdminUserController.cs @@ -1,4 +1,5 @@ #nullable enable +using LBPUnion.ProjectLighthouse.Administration; using LBPUnion.ProjectLighthouse.Files; using LBPUnion.ProjectLighthouse.Logging; using LBPUnion.ProjectLighthouse.PlayerData.Profiles; @@ -28,7 +29,7 @@ public class AdminUserController : ControllerBase User? targetedUser = await this.database.Users.FirstOrDefaultAsync(u => u.UserId == id); if (targetedUser == null) return this.NotFound(); - targetedUser.Banned = false; + targetedUser.PermissionLevel = PermissionLevel.Default; targetedUser.BannedReason = null; await this.database.SaveChangesAsync(); diff --git a/ProjectLighthouse.Servers.Website/Pages/Admin/AdminBanUserPage.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/Admin/AdminBanUserPage.cshtml.cs index dacee993..cda7b9ad 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Admin/AdminBanUserPage.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/Admin/AdminBanUserPage.cshtml.cs @@ -1,4 +1,5 @@ #nullable enable +using LBPUnion.ProjectLighthouse.Administration; using LBPUnion.ProjectLighthouse.PlayerData.Profiles; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Types; @@ -33,7 +34,7 @@ public class AdminBanUserPage : BaseLayout this.TargetedUser = await this.Database.Users.FirstOrDefaultAsync(u => u.UserId == id); if (this.TargetedUser == null) return this.NotFound(); - this.TargetedUser.Banned = true; + this.TargetedUser.PermissionLevel = PermissionLevel.Default; this.TargetedUser.BannedReason = reason; // invalidate all currently active gametokens diff --git a/ProjectLighthouse.Servers.Website/Pages/Admin/AdminPanelUsersPage.cshtml b/ProjectLighthouse.Servers.Website/Pages/Admin/AdminPanelUsersPage.cshtml index 5642912f..2c0d1515 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Admin/AdminPanelUsersPage.cshtml +++ b/ProjectLighthouse.Servers.Website/Pages/Admin/AdminPanelUsersPage.cshtml @@ -1,4 +1,5 @@ @page "/admin/users" +@using LBPUnion.ProjectLighthouse.Administration @using LBPUnion.ProjectLighthouse.PlayerData.Profiles @using LBPUnion.ProjectLighthouse.Types @model LBPUnion.ProjectLighthouse.Servers.Website.Pages.Admin.AdminPanelUsersPage @@ -14,17 +15,37 @@
@foreach (User user in Model.Users) { - string color = "blue"; - string subtitle = "User"; - if (user.IsAdmin) + string color; + string subtitle; + + switch (user.PermissionLevel) { - color = "yellow"; - subtitle = "Admin"; - } - if (user.Banned) - { - color = "red"; - subtitle = $"Banned user! Reason: {user.BannedReason}"; + // jank but works + case PermissionLevel.Banned: + { + color = "red"; + subtitle = $"Banned user! Reason: {user.BannedReason}"; + break; + } + case PermissionLevel.Moderator: + { + color = "green"; + subtitle = "Moderator"; + break; + } + case PermissionLevel.Administrator: + { + color = "yellow"; + subtitle = "Admin"; + break; + } + case PermissionLevel.Default: + default: + { + color = "blue"; + subtitle = "User"; + break; + } } subtitle += $" (id: {user.UserId})"; diff --git a/ProjectLighthouse.Servers.Website/Pages/LoginForm.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/LoginForm.cshtml.cs index 656a0bf7..6b316ad6 100644 --- a/ProjectLighthouse.Servers.Website/Pages/LoginForm.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/LoginForm.cshtml.cs @@ -57,7 +57,7 @@ public class LoginForm : BaseLayout return this.Page(); } - if (user.Banned) + if (user.IsBanned) { Logger.Warn($"User {user.Username} (id: {user.UserId}) failed to login on web due to being banned", LogArea.Login); this.Error = "You have been banned. Please contact an administrator for more information.\nReason: " + user.BannedReason; diff --git a/ProjectLighthouse.Servers.Website/Pages/UserPage.cshtml b/ProjectLighthouse.Servers.Website/Pages/UserPage.cshtml index e3761284..fdd3135d 100644 --- a/ProjectLighthouse.Servers.Website/Pages/UserPage.cshtml +++ b/ProjectLighthouse.Servers.Website/Pages/UserPage.cshtml @@ -13,7 +13,7 @@ Model.Description = Model.ProfileUser!.Biography; } -@if (Model.ProfileUser.Banned) +@if (Model.ProfileUser.IsBanned) {

User is currently banned!

@@ -120,7 +120,7 @@

Admin Options

- @if (!Model.ProfileUser.Banned) + @if (!Model.ProfileUser.IsBanned) {
diff --git a/ProjectLighthouse.Servers.Website/Pages/UsersPage.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/UsersPage.cshtml.cs index fadb934e..63ef9bbf 100644 --- a/ProjectLighthouse.Servers.Website/Pages/UsersPage.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/UsersPage.cshtml.cs @@ -1,4 +1,5 @@ #nullable enable +using LBPUnion.ProjectLighthouse.Administration; using LBPUnion.ProjectLighthouse.Configuration; using LBPUnion.ProjectLighthouse.PlayerData.Profiles; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; @@ -29,14 +30,14 @@ public class UsersPage : BaseLayout this.SearchValue = name.Replace(" ", string.Empty); - this.UserCount = await this.Database.Users.CountAsync(u => !u.Banned && u.Username.Contains(this.SearchValue)); + this.UserCount = await this.Database.Users.CountAsync(u => u.PermissionLevel != PermissionLevel.Banned && u.Username.Contains(this.SearchValue)); this.PageNumber = pageNumber; this.PageAmount = Math.Max(1, (int)Math.Ceiling((double)this.UserCount / ServerStatics.PageSize)); if (this.PageNumber < 0 || this.PageNumber >= this.PageAmount) return this.Redirect($"/users/{Math.Clamp(this.PageNumber, 0, this.PageAmount - 1)}"); - this.Users = await this.Database.Users.Where(u => !u.Banned && u.Username.Contains(this.SearchValue)) + this.Users = await this.Database.Users.Where(u => u.PermissionLevel != PermissionLevel.Banned && u.Username.Contains(this.SearchValue)) .OrderByDescending(b => b.UserId) .Skip(pageNumber * ServerStatics.PageSize) .Take(ServerStatics.PageSize) diff --git a/ProjectLighthouse.Tests.WebsiteTests/Tests/AdminTests.cs b/ProjectLighthouse.Tests.WebsiteTests/Tests/AdminTests.cs index 9c137086..f654ed7e 100644 --- a/ProjectLighthouse.Tests.WebsiteTests/Tests/AdminTests.cs +++ b/ProjectLighthouse.Tests.WebsiteTests/Tests/AdminTests.cs @@ -1,6 +1,7 @@ using System; using System.Threading.Tasks; using LBPUnion.ProjectLighthouse; +using LBPUnion.ProjectLighthouse.Administration; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.PlayerData; using LBPUnion.ProjectLighthouse.PlayerData.Profiles; @@ -28,7 +29,7 @@ public class AdminTests : LighthouseWebTest }; database.WebTokens.Add(webToken); - user.IsAdmin = true; + user.PermissionLevel = PermissionLevel.Administrator; await database.SaveChangesAsync(); this.Driver.Navigate().GoToUrl(this.BaseAddress + "/"); @@ -52,7 +53,7 @@ public class AdminTests : LighthouseWebTest }; database.WebTokens.Add(webToken); - user.IsAdmin = false; + user.PermissionLevel = PermissionLevel.Default; await database.SaveChangesAsync(); this.Driver.Navigate().GoToUrl(this.BaseAddress + "/"); diff --git a/ProjectLighthouse/Administration/Maintenance/Commands/MakeUserAdminCommand.cs b/ProjectLighthouse/Administration/Maintenance/Commands/MakeUserAdminCommand.cs index 0cc0f85f..8e78dff5 100644 --- a/ProjectLighthouse/Administration/Maintenance/Commands/MakeUserAdminCommand.cs +++ b/ProjectLighthouse/Administration/Maintenance/Commands/MakeUserAdminCommand.cs @@ -35,7 +35,7 @@ public class MakeUserAdminCommand : ICommand return; } - user.IsAdmin = true; + user.PermissionLevel = PermissionLevel.Administrator; await this.database.SaveChangesAsync(); logger.LogSuccess($"The user {user.Username} (id: {user.UserId}) is now an admin.", LogArea.Command); diff --git a/ProjectLighthouse/Administration/PermissionLevel.cs b/ProjectLighthouse/Administration/PermissionLevel.cs new file mode 100644 index 00000000..43cf61c0 --- /dev/null +++ b/ProjectLighthouse/Administration/PermissionLevel.cs @@ -0,0 +1,9 @@ +namespace LBPUnion.ProjectLighthouse.Administration; + +public enum PermissionLevel +{ + Banned = 0, + Default = 1, + Moderator = 2, + Administrator = 3, +} \ No newline at end of file diff --git a/ProjectLighthouse/Helpers/StatisticsHelper.cs b/ProjectLighthouse/Helpers/StatisticsHelper.cs index a03b03ab..a44c6fbc 100644 --- a/ProjectLighthouse/Helpers/StatisticsHelper.cs +++ b/ProjectLighthouse/Helpers/StatisticsHelper.cs @@ -1,5 +1,6 @@ using System.Linq; using System.Threading.Tasks; +using LBPUnion.ProjectLighthouse.Administration; using LBPUnion.ProjectLighthouse.PlayerData; using LBPUnion.ProjectLighthouse.Types; using Microsoft.EntityFrameworkCore; @@ -18,7 +19,7 @@ public static class StatisticsHelper public static async Task SlotCount() => await database.Slots.CountAsync(); - public static async Task UserCount() => await database.Users.CountAsync(u => !u.Banned); + public static async Task UserCount() => await database.Users.CountAsync(u => u.PermissionLevel != PermissionLevel.Banned); public static async Task TeamPickCount() => await database.Slots.CountAsync(s => s.TeamPick); diff --git a/ProjectLighthouse/Migrations/20220522192158_SwitchToPermissionLevels.cs b/ProjectLighthouse/Migrations/20220522192158_SwitchToPermissionLevels.cs new file mode 100644 index 00000000..df995542 --- /dev/null +++ b/ProjectLighthouse/Migrations/20220522192158_SwitchToPermissionLevels.cs @@ -0,0 +1,56 @@ + + +#nullable disable + +using LBPUnion.ProjectLighthouse; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace ProjectLighthouse.Migrations +{ + [DbContext(typeof(Database))] + [Migration("20220522192158_SwitchToPermissionLevels")] + public class SwitchToPermissionLevels : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn(name: "PermissionLevel", + table: "Users", + type: "int", + nullable: false, + defaultValue: 1); + + migrationBuilder.Sql("UPDATE Users SET PermissionLevel = 3 WHERE IsAdmin"); + migrationBuilder.Sql("UPDATE Users SET PermissionLevel = 0 WHERE Banned"); + + migrationBuilder.DropColumn( + name: "Banned", + table: "Users"); + + migrationBuilder.DropColumn( + name: "IsAdmin", + table: "Users"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "PermissionLevel", + table: "Users"); + + migrationBuilder.AddColumn( + name: "Banned", + table: "Users", + type: "tinyint(1)", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "IsAdmin", + table: "Users", + type: "tinyint(1)", + nullable: false, + defaultValue: false); + } + } +} diff --git a/ProjectLighthouse/Migrations/DatabaseModelSnapshot.cs b/ProjectLighthouse/Migrations/DatabaseModelSnapshot.cs index 6acb3ff5..0053459b 100644 --- a/ProjectLighthouse/Migrations/DatabaseModelSnapshot.cs +++ b/ProjectLighthouse/Migrations/DatabaseModelSnapshot.cs @@ -15,35 +15,56 @@ namespace ProjectLighthouse.Migrations { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "6.0.4") + .HasAnnotation("ProductVersion", "6.0.5") .HasAnnotation("Relational:MaxIdentifierLength", 64); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.AuthenticationAttempt", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Administration.Reports.GriefReport", b => { - b.Property("AuthenticationAttemptId") + b.Property("ReportId") .ValueGeneratedOnAdd() .HasColumnType("int"); - b.Property("GameTokenId") - .HasColumnType("int"); - - b.Property("IPAddress") + b.Property("Bounds") .HasColumnType("longtext"); - b.Property("Platform") + b.Property("GriefStateHash") + .HasColumnType("longtext"); + + b.Property("InitialStateHash") + .HasColumnType("longtext"); + + b.Property("JpegHash") + .HasColumnType("longtext"); + + b.Property("LevelId") + .HasColumnType("int"); + + b.Property("LevelOwner") + .HasColumnType("longtext"); + + b.Property("LevelType") + .HasColumnType("longtext"); + + b.Property("Players") + .HasColumnType("longtext"); + + b.Property("ReportingPlayerId") .HasColumnType("int"); b.Property("Timestamp") .HasColumnType("bigint"); - b.HasKey("AuthenticationAttemptId"); + b.Property("Type") + .HasColumnType("int"); - b.HasIndex("GameTokenId"); + b.HasKey("ReportId"); - b.ToTable("AuthenticationAttempts"); + b.HasIndex("ReportingPlayerId"); + + b.ToTable("Reports"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Categories.DatabaseCategory", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Levels.Categories.DatabaseCategory", b => { b.Property("CategoryId") .ValueGeneratedOnAdd() @@ -69,62 +90,7 @@ namespace ProjectLighthouse.Migrations b.ToTable("CustomCategories"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.GameToken", b => - { - b.Property("TokenId") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Approved") - .HasColumnType("tinyint(1)"); - - b.Property("GameVersion") - .HasColumnType("int"); - - b.Property("Platform") - .HasColumnType("int"); - - b.Property("Used") - .HasColumnType("tinyint(1)"); - - b.Property("UserId") - .HasColumnType("int"); - - b.Property("UserLocation") - .HasColumnType("longtext"); - - b.Property("UserToken") - .HasColumnType("longtext"); - - b.HasKey("TokenId"); - - b.HasIndex("UserId"); - - b.ToTable("GameTokens"); - }); - - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.HeartedProfile", b => - { - b.Property("HeartedProfileId") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("HeartedUserId") - .HasColumnType("int"); - - b.Property("UserId") - .HasColumnType("int"); - - b.HasKey("HeartedProfileId"); - - b.HasIndex("HeartedUserId"); - - b.HasIndex("UserId"); - - b.ToTable("HeartedProfiles"); - }); - - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Levels.HeartedLevel", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Levels.HeartedLevel", b => { b.Property("HeartedLevelId") .ValueGeneratedOnAdd() @@ -145,7 +111,7 @@ namespace ProjectLighthouse.Migrations b.ToTable("HeartedLevels"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Levels.QueuedLevel", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Levels.QueuedLevel", b => { b.Property("QueuedLevelId") .ValueGeneratedOnAdd() @@ -166,7 +132,7 @@ namespace ProjectLighthouse.Migrations b.ToTable("QueuedLevels"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Levels.RatedLevel", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Levels.RatedLevel", b => { b.Property("RatedLevelId") .ValueGeneratedOnAdd() @@ -193,7 +159,7 @@ namespace ProjectLighthouse.Migrations b.ToTable("RatedLevels"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Levels.Slot", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Levels.Slot", b => { b.Property("SlotId") .ValueGeneratedOnAdd() @@ -318,7 +284,7 @@ namespace ProjectLighthouse.Migrations b.ToTable("Slots"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Levels.VisitedLevel", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Levels.VisitedLevel", b => { b.Property("VisitedLevelId") .ValueGeneratedOnAdd() @@ -351,7 +317,66 @@ namespace ProjectLighthouse.Migrations b.ToTable("VisitedLevels"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Photo", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.PlayerData.AuthenticationAttempt", b => + { + b.Property("AuthenticationAttemptId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("GameTokenId") + .HasColumnType("int"); + + b.Property("IPAddress") + .HasColumnType("longtext"); + + b.Property("Platform") + .HasColumnType("int"); + + b.Property("Timestamp") + .HasColumnType("bigint"); + + b.HasKey("AuthenticationAttemptId"); + + b.HasIndex("GameTokenId"); + + b.ToTable("AuthenticationAttempts"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.PlayerData.GameToken", b => + { + b.Property("TokenId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Approved") + .HasColumnType("tinyint(1)"); + + b.Property("GameVersion") + .HasColumnType("int"); + + b.Property("Platform") + .HasColumnType("int"); + + b.Property("Used") + .HasColumnType("tinyint(1)"); + + b.Property("UserId") + .HasColumnType("int"); + + b.Property("UserLocation") + .HasColumnType("longtext"); + + b.Property("UserToken") + .HasColumnType("longtext"); + + b.HasKey("TokenId"); + + b.HasIndex("UserId"); + + b.ToTable("GameTokens"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.PlayerData.Photo", b => { b.Property("PhotoId") .ValueGeneratedOnAdd() @@ -390,7 +415,7 @@ namespace ProjectLighthouse.Migrations b.ToTable("Photos"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.PhotoSubject", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.PlayerData.PhotoSubject", b => { b.Property("PhotoSubjectId") .ValueGeneratedOnAdd() @@ -409,7 +434,7 @@ namespace ProjectLighthouse.Migrations b.ToTable("PhotoSubjects"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Profiles.Comment", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.PlayerData.Profiles.Comment", b => { b.Property("CommentId") .ValueGeneratedOnAdd() @@ -452,7 +477,7 @@ namespace ProjectLighthouse.Migrations b.ToTable("Comments"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Profiles.Email.EmailSetToken", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.PlayerData.Profiles.Email.EmailSetToken", b => { b.Property("EmailSetTokenId") .ValueGeneratedOnAdd() @@ -471,7 +496,7 @@ namespace ProjectLighthouse.Migrations b.ToTable("EmailSetTokens"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Profiles.Email.EmailVerificationToken", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.PlayerData.Profiles.Email.EmailVerificationToken", b => { b.Property("EmailVerificationTokenId") .ValueGeneratedOnAdd() @@ -490,7 +515,28 @@ namespace ProjectLighthouse.Migrations b.ToTable("EmailVerificationTokens"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Profiles.LastContact", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.PlayerData.Profiles.HeartedProfile", b => + { + b.Property("HeartedProfileId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("HeartedUserId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("HeartedProfileId"); + + b.HasIndex("HeartedUserId"); + + b.HasIndex("UserId"); + + b.ToTable("HeartedProfiles"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.PlayerData.Profiles.LastContact", b => { b.Property("UserId") .HasColumnType("int"); @@ -509,7 +555,7 @@ namespace ProjectLighthouse.Migrations b.ToTable("LastContacts"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Profiles.Location", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.PlayerData.Profiles.Location", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -526,7 +572,107 @@ namespace ProjectLighthouse.Migrations b.ToTable("Locations"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Reaction", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.PlayerData.Profiles.User", b => + { + b.Property("UserId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("AdminGrantedSlots") + .HasColumnType("int"); + + b.Property("BannedReason") + .HasColumnType("longtext"); + + b.Property("Biography") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("BooHash") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("EmailAddress") + .HasColumnType("longtext"); + + b.Property("EmailAddressVerified") + .HasColumnType("tinyint(1)"); + + b.Property("Game") + .HasColumnType("int"); + + b.Property("IconHash") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("LocationId") + .HasColumnType("int"); + + b.Property("MehHash") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Password") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PasswordResetRequired") + .HasColumnType("tinyint(1)"); + + b.Property("PermissionLevel") + .HasColumnType("int"); + + b.Property("Pins") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PlanetHashLBP2") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PlanetHashLBP3") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PlanetHashLBPVita") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Username") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("YayHash") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("UserId"); + + b.HasIndex("LocationId"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.PlayerData.Profiles.UserApprovedIpAddress", b => + { + b.Property("UserApprovedIpAddressId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("IpAddress") + .HasColumnType("longtext"); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("UserApprovedIpAddressId"); + + b.HasIndex("UserId"); + + b.ToTable("UserApprovedIpAddresses"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.PlayerData.Reaction", b => { b.Property("RatingId") .ValueGeneratedOnAdd() @@ -546,53 +692,7 @@ namespace ProjectLighthouse.Migrations b.ToTable("Reactions"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Reports.GriefReport", b => - { - b.Property("ReportId") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Bounds") - .HasColumnType("longtext"); - - b.Property("GriefStateHash") - .HasColumnType("longtext"); - - b.Property("InitialStateHash") - .HasColumnType("longtext"); - - b.Property("JpegHash") - .HasColumnType("longtext"); - - b.Property("LevelId") - .HasColumnType("int"); - - b.Property("LevelOwner") - .HasColumnType("longtext"); - - b.Property("LevelType") - .HasColumnType("longtext"); - - b.Property("Players") - .HasColumnType("longtext"); - - b.Property("ReportingPlayerId") - .HasColumnType("int"); - - b.Property("Timestamp") - .HasColumnType("bigint"); - - b.Property("Type") - .HasColumnType("int"); - - b.HasKey("ReportId"); - - b.HasIndex("ReportingPlayerId"); - - b.ToTable("Reports"); - }); - - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Reviews.RatedReview", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.PlayerData.Reviews.RatedReview", b => { b.Property("RatedReviewId") .ValueGeneratedOnAdd() @@ -616,7 +716,7 @@ namespace ProjectLighthouse.Migrations b.ToTable("RatedReviews"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Reviews.Review", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.PlayerData.Reviews.Review", b => { b.Property("ReviewId") .ValueGeneratedOnAdd() @@ -663,7 +763,7 @@ namespace ProjectLighthouse.Migrations b.ToTable("Reviews"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Score", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.PlayerData.Score", b => { b.Property("ScoreId") .ValueGeneratedOnAdd() @@ -688,99 +788,7 @@ namespace ProjectLighthouse.Migrations b.ToTable("Scores"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.User", b => - { - b.Property("UserId") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("AdminGrantedSlots") - .HasColumnType("int"); - - b.Property("Banned") - .HasColumnType("tinyint(1)"); - - b.Property("BannedReason") - .HasColumnType("longtext"); - - b.Property("Biography") - .HasColumnType("longtext"); - - b.Property("BooHash") - .HasColumnType("longtext"); - - b.Property("EmailAddress") - .HasColumnType("longtext"); - - b.Property("EmailAddressVerified") - .HasColumnType("tinyint(1)"); - - b.Property("Game") - .HasColumnType("int"); - - b.Property("IconHash") - .HasColumnType("longtext"); - - b.Property("IsAdmin") - .HasColumnType("tinyint(1)"); - - b.Property("LocationId") - .HasColumnType("int"); - - b.Property("MehHash") - .HasColumnType("longtext"); - - b.Property("Password") - .HasColumnType("longtext"); - - b.Property("PasswordResetRequired") - .HasColumnType("tinyint(1)"); - - b.Property("Pins") - .HasColumnType("longtext"); - - b.Property("PlanetHashLBP2") - .HasColumnType("longtext"); - - b.Property("PlanetHashLBP3") - .HasColumnType("longtext"); - - b.Property("PlanetHashLBPVita") - .HasColumnType("longtext"); - - b.Property("Username") - .HasColumnType("longtext"); - - b.Property("YayHash") - .HasColumnType("longtext"); - - b.HasKey("UserId"); - - b.HasIndex("LocationId"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.UserApprovedIpAddress", b => - { - b.Property("UserApprovedIpAddressId") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("IpAddress") - .HasColumnType("longtext"); - - b.Property("UserId") - .HasColumnType("int"); - - b.HasKey("UserApprovedIpAddressId"); - - b.HasIndex("UserId"); - - b.ToTable("UserApprovedIpAddresses"); - }); - - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.WebToken", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.PlayerData.WebToken", b => { b.Property("TokenId") .ValueGeneratedOnAdd() @@ -797,9 +805,115 @@ namespace ProjectLighthouse.Migrations b.ToTable("WebTokens"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.AuthenticationAttempt", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Administration.Reports.GriefReport", b => { - b.HasOne("LBPUnion.ProjectLighthouse.Types.GameToken", "GameToken") + b.HasOne("LBPUnion.ProjectLighthouse.PlayerData.Profiles.User", "ReportingPlayer") + .WithMany() + .HasForeignKey("ReportingPlayerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ReportingPlayer"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Levels.HeartedLevel", b => + { + b.HasOne("LBPUnion.ProjectLighthouse.Levels.Slot", "Slot") + .WithMany() + .HasForeignKey("SlotId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("LBPUnion.ProjectLighthouse.PlayerData.Profiles.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Slot"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Levels.QueuedLevel", b => + { + b.HasOne("LBPUnion.ProjectLighthouse.Levels.Slot", "Slot") + .WithMany() + .HasForeignKey("SlotId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("LBPUnion.ProjectLighthouse.PlayerData.Profiles.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Slot"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Levels.RatedLevel", b => + { + b.HasOne("LBPUnion.ProjectLighthouse.Levels.Slot", "Slot") + .WithMany() + .HasForeignKey("SlotId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("LBPUnion.ProjectLighthouse.PlayerData.Profiles.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Slot"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Levels.Slot", b => + { + b.HasOne("LBPUnion.ProjectLighthouse.PlayerData.Profiles.User", "Creator") + .WithMany() + .HasForeignKey("CreatorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("LBPUnion.ProjectLighthouse.PlayerData.Profiles.Location", "Location") + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Creator"); + + b.Navigation("Location"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Levels.VisitedLevel", b => + { + b.HasOne("LBPUnion.ProjectLighthouse.Levels.Slot", "Slot") + .WithMany() + .HasForeignKey("SlotId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("LBPUnion.ProjectLighthouse.PlayerData.Profiles.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Slot"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.PlayerData.AuthenticationAttempt", b => + { + b.HasOne("LBPUnion.ProjectLighthouse.PlayerData.GameToken", "GameToken") .WithMany() .HasForeignKey("GameTokenId") .OnDelete(DeleteBehavior.Cascade) @@ -808,9 +922,9 @@ namespace ProjectLighthouse.Migrations b.Navigation("GameToken"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.GameToken", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.PlayerData.GameToken", b => { - b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "User") + b.HasOne("LBPUnion.ProjectLighthouse.PlayerData.Profiles.User", "User") .WithMany() .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Cascade) @@ -819,15 +933,70 @@ namespace ProjectLighthouse.Migrations b.Navigation("User"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.HeartedProfile", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.PlayerData.Photo", b => { - b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "HeartedUser") + b.HasOne("LBPUnion.ProjectLighthouse.PlayerData.Profiles.User", "Creator") + .WithMany() + .HasForeignKey("CreatorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Creator"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.PlayerData.PhotoSubject", b => + { + b.HasOne("LBPUnion.ProjectLighthouse.PlayerData.Profiles.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.PlayerData.Profiles.Comment", b => + { + b.HasOne("LBPUnion.ProjectLighthouse.PlayerData.Profiles.User", "Poster") + .WithMany() + .HasForeignKey("PosterUserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Poster"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.PlayerData.Profiles.Email.EmailSetToken", b => + { + b.HasOne("LBPUnion.ProjectLighthouse.PlayerData.Profiles.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.PlayerData.Profiles.Email.EmailVerificationToken", b => + { + b.HasOne("LBPUnion.ProjectLighthouse.PlayerData.Profiles.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.PlayerData.Profiles.HeartedProfile", b => + { + b.HasOne("LBPUnion.ProjectLighthouse.PlayerData.Profiles.User", "HeartedUser") .WithMany() .HasForeignKey("HeartedUserId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "User") + b.HasOne("LBPUnion.ProjectLighthouse.PlayerData.Profiles.User", "User") .WithMany() .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Cascade) @@ -838,115 +1007,31 @@ namespace ProjectLighthouse.Migrations b.Navigation("User"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Levels.HeartedLevel", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.PlayerData.Profiles.LastContact", b => { - b.HasOne("LBPUnion.ProjectLighthouse.Types.Levels.Slot", "Slot") - .WithMany() - .HasForeignKey("SlotId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "User") + b.HasOne("LBPUnion.ProjectLighthouse.PlayerData.Profiles.User", "User") .WithMany() .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.Navigation("Slot"); - b.Navigation("User"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Levels.QueuedLevel", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.PlayerData.Profiles.User", b => { - b.HasOne("LBPUnion.ProjectLighthouse.Types.Levels.Slot", "Slot") - .WithMany() - .HasForeignKey("SlotId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Slot"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Levels.RatedLevel", b => - { - b.HasOne("LBPUnion.ProjectLighthouse.Types.Levels.Slot", "Slot") - .WithMany() - .HasForeignKey("SlotId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Slot"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Levels.Slot", b => - { - b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "Creator") - .WithMany() - .HasForeignKey("CreatorId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("LBPUnion.ProjectLighthouse.Types.Profiles.Location", "Location") + b.HasOne("LBPUnion.ProjectLighthouse.PlayerData.Profiles.Location", "Location") .WithMany() .HasForeignKey("LocationId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.Navigation("Creator"); - b.Navigation("Location"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Levels.VisitedLevel", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.PlayerData.Profiles.UserApprovedIpAddress", b => { - b.HasOne("LBPUnion.ProjectLighthouse.Types.Levels.Slot", "Slot") - .WithMany() - .HasForeignKey("SlotId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Slot"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Photo", b => - { - b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "Creator") - .WithMany() - .HasForeignKey("CreatorId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Creator"); - }); - - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.PhotoSubject", b => - { - b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "User") + b.HasOne("LBPUnion.ProjectLighthouse.PlayerData.Profiles.User", "User") .WithMany() .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Cascade) @@ -955,70 +1040,15 @@ namespace ProjectLighthouse.Migrations b.Navigation("User"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Profiles.Comment", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.PlayerData.Reviews.RatedReview", b => { - b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "Poster") - .WithMany() - .HasForeignKey("PosterUserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Poster"); - }); - - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Profiles.Email.EmailSetToken", b => - { - b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Profiles.Email.EmailVerificationToken", b => - { - b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Profiles.LastContact", b => - { - b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Reports.GriefReport", b => - { - b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "ReportingPlayer") - .WithMany() - .HasForeignKey("ReportingPlayerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("ReportingPlayer"); - }); - - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Reviews.RatedReview", b => - { - b.HasOne("LBPUnion.ProjectLighthouse.Types.Reviews.Review", "Review") + b.HasOne("LBPUnion.ProjectLighthouse.PlayerData.Reviews.Review", "Review") .WithMany() .HasForeignKey("ReviewId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "User") + b.HasOne("LBPUnion.ProjectLighthouse.PlayerData.Profiles.User", "User") .WithMany() .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Cascade) @@ -1029,15 +1059,15 @@ namespace ProjectLighthouse.Migrations b.Navigation("User"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Reviews.Review", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.PlayerData.Reviews.Review", b => { - b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "Reviewer") + b.HasOne("LBPUnion.ProjectLighthouse.PlayerData.Profiles.User", "Reviewer") .WithMany() .HasForeignKey("ReviewerId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("LBPUnion.ProjectLighthouse.Types.Levels.Slot", "Slot") + b.HasOne("LBPUnion.ProjectLighthouse.Levels.Slot", "Slot") .WithMany() .HasForeignKey("SlotId") .OnDelete(DeleteBehavior.Cascade) @@ -1048,9 +1078,9 @@ namespace ProjectLighthouse.Migrations b.Navigation("Slot"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Score", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.PlayerData.Score", b => { - b.HasOne("LBPUnion.ProjectLighthouse.Types.Levels.Slot", "Slot") + b.HasOne("LBPUnion.ProjectLighthouse.Levels.Slot", "Slot") .WithMany() .HasForeignKey("SlotId") .OnDelete(DeleteBehavior.Cascade) @@ -1058,28 +1088,6 @@ namespace ProjectLighthouse.Migrations b.Navigation("Slot"); }); - - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.User", b => - { - b.HasOne("LBPUnion.ProjectLighthouse.Types.Profiles.Location", "Location") - .WithMany() - .HasForeignKey("LocationId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Location"); - }); - - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.UserApprovedIpAddress", b => - { - b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("User"); - }); #pragma warning restore 612, 618 } } diff --git a/ProjectLighthouse/PlayerData/Profiles/User.cs b/ProjectLighthouse/PlayerData/Profiles/User.cs index 300345d2..83300d8a 100644 --- a/ProjectLighthouse/PlayerData/Profiles/User.cs +++ b/ProjectLighthouse/PlayerData/Profiles/User.cs @@ -3,6 +3,7 @@ using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Text.Json.Serialization; using System.Xml.Serialization; +using LBPUnion.ProjectLighthouse.Administration; using LBPUnion.ProjectLighthouse.Configuration; using LBPUnion.ProjectLighthouse.Serialization; using LBPUnion.ProjectLighthouse.Types; @@ -15,7 +16,6 @@ public class User [NotMapped] [JsonIgnore] private Database? _database; - #nullable disable [NotMapped] [JsonIgnore] @@ -123,9 +123,6 @@ public class User [JsonIgnore] public int Hearts => this.database.HeartedProfiles.Count(s => s.HeartedUserId == this.UserId); - [JsonIgnore] - public bool IsAdmin { get; set; } = false; - [JsonIgnore] public bool PasswordResetRequired { get; set; } @@ -138,10 +135,19 @@ public class User public UserStatus Status => new(this.database, this.UserId); [JsonIgnore] - public bool Banned { get; set; } + public bool IsBanned => this.PermissionLevel == PermissionLevel.Banned; [JsonIgnore] - public string BannedReason { get; set; } + public bool IsModerator => this.PermissionLevel == PermissionLevel.Moderator; + + [JsonIgnore] + public bool IsAdmin => this.PermissionLevel == PermissionLevel.Administrator; + + [JsonIgnore] + public PermissionLevel PermissionLevel { get; set; } = PermissionLevel.Default; + + [JsonIgnore] + public string? BannedReason { get; set; } public string Serialize(GameVersion gameVersion = GameVersion.LittleBigPlanet1) { diff --git a/ProjectLighthouse/ProjectLighthouse.csproj b/ProjectLighthouse/ProjectLighthouse.csproj index 903e3e3b..4df7087c 100644 --- a/ProjectLighthouse/ProjectLighthouse.csproj +++ b/ProjectLighthouse/ProjectLighthouse.csproj @@ -50,6 +50,10 @@ + + + + diff --git a/scripts-and-tools/create-migration.sh b/scripts-and-tools/create-migration.sh index 5ccbe0fb..ab89099f 100755 --- a/scripts-and-tools/create-migration.sh +++ b/scripts-and-tools/create-migration.sh @@ -1,4 +1,4 @@ #!/bin/bash export LIGHTHOUSE_DB_CONNECTION_STRING='server=127.0.0.1;uid=root;pwd=lighthouse;database=lighthouse' -dotnet ef migrations add "$1" --project ProjectLighthouse \ No newline at end of file +dotnet ef migrations add "$1" --project ../ProjectLighthouse \ No newline at end of file