From 0d5139489ae80b3ade94853458581bee8eea4bfd Mon Sep 17 00:00:00 2001 From: jvyden Date: Fri, 19 Nov 2021 21:35:15 -0500 Subject: [PATCH 001/123] Add razor page support --- ProjectLighthouse/Helpers/GitVersionHelper.cs | 2 ++ .../Pages/ExternalAuth/LandingPage.cshtml | 21 +++++++++++++++++++ .../Pages/ExternalAuth/LandingPage.cshtml.cs | 10 +++++++++ ProjectLighthouse/Program.cs | 2 +- ProjectLighthouse/ProjectLighthouse.csproj | 4 ++++ ProjectLighthouse/Startup.cs | 4 +++- 6 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 ProjectLighthouse/Pages/ExternalAuth/LandingPage.cshtml create mode 100644 ProjectLighthouse/Pages/ExternalAuth/LandingPage.cshtml.cs diff --git a/ProjectLighthouse/Helpers/GitVersionHelper.cs b/ProjectLighthouse/Helpers/GitVersionHelper.cs index 857728fe..bc4e8cad 100644 --- a/ProjectLighthouse/Helpers/GitVersionHelper.cs +++ b/ProjectLighthouse/Helpers/GitVersionHelper.cs @@ -2,6 +2,7 @@ using System; using System.IO; using Kettu; using LBPUnion.ProjectLighthouse.Logging; +using LBPUnion.ProjectLighthouse.Types.Settings; namespace LBPUnion.ProjectLighthouse.Helpers { @@ -50,6 +51,7 @@ namespace LBPUnion.ProjectLighthouse.Helpers public static string CommitHash { get; set; } public static string Branch { get; set; } + public static string FullVersion => $"{ServerStatics.ServerName} {Branch}@{CommitHash}"; public static bool IsDirty => CommitHash.EndsWith("-dirty"); public static bool CanCheckForUpdates { get; set; } } diff --git a/ProjectLighthouse/Pages/ExternalAuth/LandingPage.cshtml b/ProjectLighthouse/Pages/ExternalAuth/LandingPage.cshtml new file mode 100644 index 00000000..b55f7660 --- /dev/null +++ b/ProjectLighthouse/Pages/ExternalAuth/LandingPage.cshtml @@ -0,0 +1,21 @@ +@page "/" +@using LBPUnion.ProjectLighthouse.Helpers +@model LBPUnion.ProjectLighthouse.Controllers.ExternalAuth.LandingPage + +@{ + Layout = null; +} + + + + + + Project Lighthouse External Auth + + +test + + + \ No newline at end of file diff --git a/ProjectLighthouse/Pages/ExternalAuth/LandingPage.cshtml.cs b/ProjectLighthouse/Pages/ExternalAuth/LandingPage.cshtml.cs new file mode 100644 index 00000000..1259e5a7 --- /dev/null +++ b/ProjectLighthouse/Pages/ExternalAuth/LandingPage.cshtml.cs @@ -0,0 +1,10 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; + +namespace LBPUnion.ProjectLighthouse.Controllers.ExternalAuth +{ + public class LandingPage : PageModel + { + public IActionResult OnGet() => this.Page(); + } +} \ No newline at end of file diff --git a/ProjectLighthouse/Program.cs b/ProjectLighthouse/Program.cs index 695e2470..6b7a1a96 100644 --- a/ProjectLighthouse/Program.cs +++ b/ProjectLighthouse/Program.cs @@ -29,7 +29,7 @@ namespace LBPUnion.ProjectLighthouse Logger.AddLogger(new LighthouseFileLogger()); Logger.Log("Welcome to Project Lighthouse!", LoggerLevelStartup.Instance); - Logger.Log($"Running {ServerStatics.ServerName} {GitVersionHelper.CommitHash}@{GitVersionHelper.Branch}", LoggerLevelStartup.Instance); + Logger.Log($"Running {GitVersionHelper.FullVersion}", LoggerLevelStartup.Instance); // This loads the config, see ServerSettings.cs for more information Logger.Log("Loaded config file version " + ServerSettings.Instance.ConfigVersion, LoggerLevelStartup.Instance); diff --git a/ProjectLighthouse/ProjectLighthouse.csproj b/ProjectLighthouse/ProjectLighthouse.csproj index b576a35c..3bf71b1a 100644 --- a/ProjectLighthouse/ProjectLighthouse.csproj +++ b/ProjectLighthouse/ProjectLighthouse.csproj @@ -32,6 +32,10 @@ + + + + diff --git a/ProjectLighthouse/Startup.cs b/ProjectLighthouse/Startup.cs index 93e41f3d..9169a7ed 100644 --- a/ProjectLighthouse/Startup.cs +++ b/ProjectLighthouse/Startup.cs @@ -29,6 +29,7 @@ namespace LBPUnion.ProjectLighthouse public void ConfigureServices(IServiceCollection services) { services.AddControllers(); + services.AddRazorPages().WithRazorPagesAtContentRoot(); services.AddMvc ( @@ -152,7 +153,8 @@ namespace LBPUnion.ProjectLighthouse app.UseRouting(); - app.UseEndpoints(endpoints => endpoints.MapControllers()); +// app.UseEndpoints(endpoints => endpoints.MapControllers()); + app.UseEndpoints(endpoints => endpoints.MapRazorPages()); } } } \ No newline at end of file From 4738684f6ebacafcc391c5c61df0ef0e03f604f4 Mon Sep 17 00:00:00 2001 From: jvyden Date: Fri, 19 Nov 2021 21:51:33 -0500 Subject: [PATCH 002/123] Add BaseLayout All pages should be using this. --- .../Pages/ExternalAuth/LandingPage.cshtml | 18 ++---------------- .../Pages/ExternalAuth/LandingPage.cshtml.cs | 8 +++++--- .../Pages/Layouts/BaseLayout.cshtml | 16 ++++++++++++++++ .../Pages/Layouts/BaseLayout.cshtml.cs | 7 +++++++ ProjectLighthouse/ProjectLighthouse.csproj | 4 ---- ProjectLighthouse/Startup.cs | 2 +- 6 files changed, 31 insertions(+), 24 deletions(-) create mode 100644 ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml create mode 100644 ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml.cs diff --git a/ProjectLighthouse/Pages/ExternalAuth/LandingPage.cshtml b/ProjectLighthouse/Pages/ExternalAuth/LandingPage.cshtml index b55f7660..53141670 100644 --- a/ProjectLighthouse/Pages/ExternalAuth/LandingPage.cshtml +++ b/ProjectLighthouse/Pages/ExternalAuth/LandingPage.cshtml @@ -1,21 +1,7 @@ @page "/" -@using LBPUnion.ProjectLighthouse.Helpers -@model LBPUnion.ProjectLighthouse.Controllers.ExternalAuth.LandingPage +@model LBPUnion.ProjectLighthouse.Pages.ExternalAuth.LandingPage @{ - Layout = null; + Layout = "Layouts/BaseLayout"; } - - - - - - Project Lighthouse External Auth - - test - -
-

Page generated by @GitVersionHelper.FullVersion

-
- \ No newline at end of file diff --git a/ProjectLighthouse/Pages/ExternalAuth/LandingPage.cshtml.cs b/ProjectLighthouse/Pages/ExternalAuth/LandingPage.cshtml.cs index 1259e5a7..1afeec59 100644 --- a/ProjectLighthouse/Pages/ExternalAuth/LandingPage.cshtml.cs +++ b/ProjectLighthouse/Pages/ExternalAuth/LandingPage.cshtml.cs @@ -1,10 +1,12 @@ +using JetBrains.Annotations; +using LBPUnion.ProjectLighthouse.Pages.Layouts; using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; -namespace LBPUnion.ProjectLighthouse.Controllers.ExternalAuth +namespace LBPUnion.ProjectLighthouse.Pages.ExternalAuth { - public class LandingPage : PageModel + public class LandingPage : BaseLayout { + [UsedImplicitly] public IActionResult OnGet() => this.Page(); } } \ No newline at end of file diff --git a/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml b/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml new file mode 100644 index 00000000..5a3d8255 --- /dev/null +++ b/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml @@ -0,0 +1,16 @@ +@using LBPUnion.ProjectLighthouse.Helpers +@model LBPUnion.ProjectLighthouse.Pages.Layouts.BaseLayout + + + + + + Project Lighthouse + + +@RenderBody() + +
+

Page generated by @GitVersionHelper.FullVersion

+
+ \ No newline at end of file diff --git a/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml.cs b/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml.cs new file mode 100644 index 00000000..df4a1a2f --- /dev/null +++ b/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml.cs @@ -0,0 +1,7 @@ +using Microsoft.AspNetCore.Mvc.RazorPages; + +namespace LBPUnion.ProjectLighthouse.Pages.Layouts +{ + public class BaseLayout : PageModel + {} +} \ No newline at end of file diff --git a/ProjectLighthouse/ProjectLighthouse.csproj b/ProjectLighthouse/ProjectLighthouse.csproj index 3bf71b1a..b576a35c 100644 --- a/ProjectLighthouse/ProjectLighthouse.csproj +++ b/ProjectLighthouse/ProjectLighthouse.csproj @@ -32,10 +32,6 @@ - - - - diff --git a/ProjectLighthouse/Startup.cs b/ProjectLighthouse/Startup.cs index 9169a7ed..01dbe063 100644 --- a/ProjectLighthouse/Startup.cs +++ b/ProjectLighthouse/Startup.cs @@ -153,7 +153,7 @@ namespace LBPUnion.ProjectLighthouse app.UseRouting(); -// app.UseEndpoints(endpoints => endpoints.MapControllers()); + app.UseEndpoints(endpoints => endpoints.MapControllers()); app.UseEndpoints(endpoints => endpoints.MapRazorPages()); } } From a31085c08afccb87f4e7d607d8e4ab535b30b63b Mon Sep 17 00:00:00 2001 From: jvyden Date: Fri, 19 Nov 2021 22:00:08 -0500 Subject: [PATCH 003/123] Add page navigation bar --- .../Pages/ExternalAuth/LandingPage.cshtml | 2 +- ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml | 9 +++++++++ .../Pages/Layouts/BaseLayout.cshtml.cs | 11 ++++++++++- ProjectLighthouse/Types/PageNavigationItem.cs | 13 +++++++++++++ 4 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 ProjectLighthouse/Types/PageNavigationItem.cs diff --git a/ProjectLighthouse/Pages/ExternalAuth/LandingPage.cshtml b/ProjectLighthouse/Pages/ExternalAuth/LandingPage.cshtml index 53141670..9cf7302c 100644 --- a/ProjectLighthouse/Pages/ExternalAuth/LandingPage.cshtml +++ b/ProjectLighthouse/Pages/ExternalAuth/LandingPage.cshtml @@ -4,4 +4,4 @@ @{ Layout = "Layouts/BaseLayout"; } -test +

Welcome to Project Lighthouse.

\ No newline at end of file diff --git a/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml b/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml index 5a3d8255..13b53fff 100644 --- a/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml +++ b/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml @@ -1,4 +1,5 @@ @using LBPUnion.ProjectLighthouse.Helpers +@using LBPUnion.ProjectLighthouse.Types @model LBPUnion.ProjectLighthouse.Pages.Layouts.BaseLayout @@ -7,6 +8,14 @@ Project Lighthouse +
+ +
@RenderBody() diff --git a/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml.cs b/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml.cs index df4a1a2f..cfcd8349 100644 --- a/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml.cs +++ b/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml.cs @@ -1,7 +1,16 @@ +using System.Collections.Generic; +using LBPUnion.ProjectLighthouse.Types; using Microsoft.AspNetCore.Mvc.RazorPages; namespace LBPUnion.ProjectLighthouse.Pages.Layouts { public class BaseLayout : PageModel - {} + { + public readonly List NavigationItems = new() + { + new PageNavigationItem("Home", "/"), + new PageNavigationItem("Register", "/register"), + new PageNavigationItem("Login", "/login"), + }; + } } \ No newline at end of file diff --git a/ProjectLighthouse/Types/PageNavigationItem.cs b/ProjectLighthouse/Types/PageNavigationItem.cs new file mode 100644 index 00000000..409622e5 --- /dev/null +++ b/ProjectLighthouse/Types/PageNavigationItem.cs @@ -0,0 +1,13 @@ +namespace LBPUnion.ProjectLighthouse.Types +{ + public class PageNavigationItem + { + public PageNavigationItem(string name, string url) + { + this.Name = name; + this.Url = url; + } + public string Name { get; set; } + public string Url { get; set; } + } +} \ No newline at end of file From 0073461e9701ea9f2785d1f8fa5274f5975e77a6 Mon Sep 17 00:00:00 2001 From: jvyden Date: Fri, 19 Nov 2021 22:06:05 -0500 Subject: [PATCH 004/123] Add modified warning to page footer --- ProjectLighthouse/Pages/ExternalAuth/LandingPage.cshtml | 2 +- ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ProjectLighthouse/Pages/ExternalAuth/LandingPage.cshtml b/ProjectLighthouse/Pages/ExternalAuth/LandingPage.cshtml index 9cf7302c..72a62f47 100644 --- a/ProjectLighthouse/Pages/ExternalAuth/LandingPage.cshtml +++ b/ProjectLighthouse/Pages/ExternalAuth/LandingPage.cshtml @@ -4,4 +4,4 @@ @{ Layout = "Layouts/BaseLayout"; } -

Welcome to Project Lighthouse.

\ No newline at end of file +

Welcome to Project Lighthouse.

\ No newline at end of file diff --git a/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml b/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml index 13b53fff..183b3fe7 100644 --- a/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml +++ b/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml @@ -21,5 +21,9 @@

Page generated by @GitVersionHelper.FullVersion

+ @if (GitVersionHelper.IsDirty) + { +

This page was generated using a modified version of Project Lighthouse. Please make sure you are properly disclosing the source code to any users who may be using this instance.

+ }
\ No newline at end of file From fc040dec50126522e15e0eeaeede34c61a0eccf8 Mon Sep 17 00:00:00 2001 From: jvyden Date: Fri, 19 Nov 2021 22:16:42 -0500 Subject: [PATCH 005/123] Add (non-functional) login form --- ProjectLighthouse/Pages/ExternalAuth/LoginForm.cshtml | 11 +++++++++++ .../Pages/ExternalAuth/LoginForm.cshtml.cs | 10 ++++++++++ ProjectLighthouse/ProjectLighthouse.csproj | 1 + ProjectLighthouse/Startup.cs | 6 +++++- 4 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 ProjectLighthouse/Pages/ExternalAuth/LoginForm.cshtml create mode 100644 ProjectLighthouse/Pages/ExternalAuth/LoginForm.cshtml.cs diff --git a/ProjectLighthouse/Pages/ExternalAuth/LoginForm.cshtml b/ProjectLighthouse/Pages/ExternalAuth/LoginForm.cshtml new file mode 100644 index 00000000..38611a97 --- /dev/null +++ b/ProjectLighthouse/Pages/ExternalAuth/LoginForm.cshtml @@ -0,0 +1,11 @@ +@page "/login" +@model LBPUnion.ProjectLighthouse.Pages.ExternalAuth.LoginForm + +@{ + Layout = "Layouts/BaseLayout"; +} +
+
+
+
+
\ No newline at end of file diff --git a/ProjectLighthouse/Pages/ExternalAuth/LoginForm.cshtml.cs b/ProjectLighthouse/Pages/ExternalAuth/LoginForm.cshtml.cs new file mode 100644 index 00000000..56009d49 --- /dev/null +++ b/ProjectLighthouse/Pages/ExternalAuth/LoginForm.cshtml.cs @@ -0,0 +1,10 @@ +using LBPUnion.ProjectLighthouse.Pages.Layouts; +using Microsoft.AspNetCore.Mvc; + +namespace LBPUnion.ProjectLighthouse.Pages.ExternalAuth +{ + public class LoginForm : BaseLayout + { + public IActionResult OnGet() => this.Page(); + } +} \ No newline at end of file diff --git a/ProjectLighthouse/ProjectLighthouse.csproj b/ProjectLighthouse/ProjectLighthouse.csproj index b576a35c..a4e601cc 100644 --- a/ProjectLighthouse/ProjectLighthouse.csproj +++ b/ProjectLighthouse/ProjectLighthouse.csproj @@ -13,6 +13,7 @@ + all diff --git a/ProjectLighthouse/Startup.cs b/ProjectLighthouse/Startup.cs index 01dbe063..18dc9c03 100644 --- a/ProjectLighthouse/Startup.cs +++ b/ProjectLighthouse/Startup.cs @@ -29,7 +29,11 @@ namespace LBPUnion.ProjectLighthouse public void ConfigureServices(IServiceCollection services) { services.AddControllers(); - services.AddRazorPages().WithRazorPagesAtContentRoot(); + #if DEBUG + services.AddRazorPages().WithRazorPagesAtContentRoot().AddRazorRuntimeCompilation(); + #else + services.AddRazorPages().WithRazorPagesAtContentRoot() + #endif services.AddMvc ( From d96f0843223cf54f7f663f16ab02971213aa9b54 Mon Sep 17 00:00:00 2001 From: jvyden Date: Fri, 19 Nov 2021 23:55:40 -0500 Subject: [PATCH 006/123] Add (working) Register Form --- .../Tests/DatabaseTests.cs | 5 +- ProjectLighthouse.Tests/Tests/SlotTests.cs | 5 +- ProjectLighthouse/Database.cs | 9 +- ...211120045239_AddPasswordToUser.Designer.cs | 654 ++++++++++++++++++ .../20211120045239_AddPasswordToUser.cs | 26 + .../Migrations/DatabaseModelSnapshot.cs | 3 + .../Pages/ExternalAuth/LoginForm.cshtml | 11 +- .../Pages/ExternalAuth/LoginForm.cshtml.cs | 31 +- .../Pages/ExternalAuth/RegisterForm.cshtml | 20 + .../Pages/ExternalAuth/RegisterForm.cshtml.cs | 44 ++ ProjectLighthouse/Types/User.cs | 1 + 11 files changed, 799 insertions(+), 10 deletions(-) create mode 100644 ProjectLighthouse/Migrations/20211120045239_AddPasswordToUser.Designer.cs create mode 100644 ProjectLighthouse/Migrations/20211120045239_AddPasswordToUser.cs create mode 100644 ProjectLighthouse/Pages/ExternalAuth/RegisterForm.cshtml create mode 100644 ProjectLighthouse/Pages/ExternalAuth/RegisterForm.cshtml.cs diff --git a/ProjectLighthouse.Tests/Tests/DatabaseTests.cs b/ProjectLighthouse.Tests/Tests/DatabaseTests.cs index f2071792..01d49d1f 100644 --- a/ProjectLighthouse.Tests/Tests/DatabaseTests.cs +++ b/ProjectLighthouse.Tests/Tests/DatabaseTests.cs @@ -1,5 +1,6 @@ using System; using System.Threading.Tasks; +using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Types; namespace LBPUnion.ProjectLighthouse.Tests @@ -12,8 +13,8 @@ namespace LBPUnion.ProjectLighthouse.Tests await using Database database = new(); int rand = new Random().Next(); - User userA = await database.CreateUser("createUserTwiceTest" + rand); - User userB = await database.CreateUser("createUserTwiceTest" + rand); + User userA = await database.CreateUser("createUserTwiceTest" + rand, HashHelper.GenerateAuthToken()); + User userB = await database.CreateUser("createUserTwiceTest" + rand, HashHelper.GenerateAuthToken()); database.Users.Remove(userA); database.Users.Remove(userB); diff --git a/ProjectLighthouse.Tests/Tests/SlotTests.cs b/ProjectLighthouse.Tests/Tests/SlotTests.cs index 52f4d690..7af3d264 100644 --- a/ProjectLighthouse.Tests/Tests/SlotTests.cs +++ b/ProjectLighthouse.Tests/Tests/SlotTests.cs @@ -1,5 +1,6 @@ using System.Net.Http; using System.Threading.Tasks; +using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Types; using LBPUnion.ProjectLighthouse.Types.Levels; using LBPUnion.ProjectLighthouse.Types.Profiles; @@ -14,8 +15,8 @@ namespace LBPUnion.ProjectLighthouse.Tests { await using Database database = new(); - User userA = await database.CreateUser("unitTestUser0"); - User userB = await database.CreateUser("unitTestUser1"); + User userA = await database.CreateUser("unitTestUser0", HashHelper.GenerateAuthToken()); + User userB = await database.CreateUser("unitTestUser1", HashHelper.GenerateAuthToken()); Location l = new() { diff --git a/ProjectLighthouse/Database.cs b/ProjectLighthouse/Database.cs index a7051327..5b1c7253 100644 --- a/ProjectLighthouse/Database.cs +++ b/ProjectLighthouse/Database.cs @@ -1,3 +1,4 @@ +using System; using System.Linq; using System.Threading.Tasks; using Kettu; @@ -32,8 +33,10 @@ namespace LBPUnion.ProjectLighthouse protected override void OnConfiguring(DbContextOptionsBuilder options) => options.UseMySql(ServerSettings.Instance.DbConnectionString, MySqlServerVersion.LatestSupportedServerVersion); - public async Task CreateUser(string username) + public async Task CreateUser(string username, string password) { + if (!password.StartsWith("$2a")) throw new ArgumentException(nameof(password) + " is not a BCrypt hash"); + User user; if ((user = await this.Users.Where(u => u.Username == username).FirstOrDefaultAsync()) != null) return user; @@ -44,6 +47,7 @@ namespace LBPUnion.ProjectLighthouse user = new User { Username = username, + Password = password, LocationId = l.Id, Biography = username + " hasn't introduced themselves yet.", }; @@ -58,7 +62,8 @@ namespace LBPUnion.ProjectLighthouse public async Task AuthenticateUser(LoginData loginData, string userLocation, string titleId = "") { // TODO: don't use psn name to authenticate - User user = await this.Users.FirstOrDefaultAsync(u => u.Username == loginData.Username) ?? await this.CreateUser(loginData.Username); + User? user = await this.Users.FirstOrDefaultAsync(u => u.Username == loginData.Username); + if (user == null) return null; Token token = new() { diff --git a/ProjectLighthouse/Migrations/20211120045239_AddPasswordToUser.Designer.cs b/ProjectLighthouse/Migrations/20211120045239_AddPasswordToUser.Designer.cs new file mode 100644 index 00000000..2f2f2a57 --- /dev/null +++ b/ProjectLighthouse/Migrations/20211120045239_AddPasswordToUser.Designer.cs @@ -0,0 +1,654 @@ +// +using LBPUnion.ProjectLighthouse; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace ProjectLighthouse.Migrations +{ + [DbContext(typeof(Database))] + [Migration("20211120045239_AddPasswordToUser")] + partial class AddPasswordToUser + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + 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 => + { + b.Property("HeartedLevelId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("SlotId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("HeartedLevelId"); + + b.HasIndex("SlotId"); + + b.HasIndex("UserId"); + + b.ToTable("HeartedLevels"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Levels.QueuedLevel", b => + { + b.Property("QueuedLevelId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("SlotId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("QueuedLevelId"); + + b.HasIndex("SlotId"); + + b.HasIndex("UserId"); + + b.ToTable("QueuedLevels"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Levels.RatedLevel", b => + { + b.Property("RatedLevelId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Rating") + .HasColumnType("int"); + + b.Property("RatingLBP1") + .HasColumnType("double"); + + b.Property("SlotId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("RatedLevelId"); + + b.HasIndex("SlotId"); + + b.HasIndex("UserId"); + + b.ToTable("RatedLevels"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Levels.Slot", b => + { + b.Property("SlotId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("AuthorLabels") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("BackgroundHash") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CreatorId") + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FirstUploaded") + .HasColumnType("bigint"); + + b.Property("GameVersion") + .HasColumnType("int"); + + b.Property("IconHash") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("InitiallyLocked") + .HasColumnType("tinyint(1)"); + + b.Property("LastUpdated") + .HasColumnType("bigint"); + + b.Property("Lbp1Only") + .HasColumnType("tinyint(1)"); + + b.Property("LevelType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("LocationId") + .HasColumnType("int"); + + b.Property("MaximumPlayers") + .HasColumnType("int"); + + b.Property("MinimumPlayers") + .HasColumnType("int"); + + b.Property("MoveRequired") + .HasColumnType("tinyint(1)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PlaysLBP1") + .HasColumnType("int"); + + b.Property("PlaysLBP1Complete") + .HasColumnType("int"); + + b.Property("PlaysLBP1Unique") + .HasColumnType("int"); + + b.Property("PlaysLBP2") + .HasColumnType("int"); + + b.Property("PlaysLBP2Complete") + .HasColumnType("int"); + + b.Property("PlaysLBP2Unique") + .HasColumnType("int"); + + b.Property("PlaysLBP3") + .HasColumnType("int"); + + b.Property("PlaysLBP3Complete") + .HasColumnType("int"); + + b.Property("PlaysLBP3Unique") + .HasColumnType("int"); + + b.Property("PlaysLBPVita") + .HasColumnType("int"); + + b.Property("PlaysLBPVitaComplete") + .HasColumnType("int"); + + b.Property("PlaysLBPVitaUnique") + .HasColumnType("int"); + + b.Property("ResourceCollection") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("RootLevel") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Shareable") + .HasColumnType("int"); + + b.Property("SubLevel") + .HasColumnType("tinyint(1)"); + + b.Property("TeamPick") + .HasColumnType("tinyint(1)"); + + b.HasKey("SlotId"); + + b.HasIndex("CreatorId"); + + b.HasIndex("LocationId"); + + b.ToTable("Slots"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Levels.VisitedLevel", b => + { + b.Property("VisitedLevelId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("PlaysLBP1") + .HasColumnType("int"); + + b.Property("PlaysLBP2") + .HasColumnType("int"); + + b.Property("PlaysLBP3") + .HasColumnType("int"); + + b.Property("PlaysLBPVita") + .HasColumnType("int"); + + b.Property("SlotId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("VisitedLevelId"); + + b.HasIndex("SlotId"); + + b.HasIndex("UserId"); + + b.ToTable("VisitedLevels"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Photo", b => + { + b.Property("PhotoId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("CreatorId") + .HasColumnType("int"); + + b.Property("LargeHash") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MediumHash") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PhotoSubjectCollection") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PlanHash") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("SmallHash") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Timestamp") + .HasColumnType("bigint"); + + b.HasKey("PhotoId"); + + b.HasIndex("CreatorId"); + + b.ToTable("Photos"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.PhotoSubject", b => + { + b.Property("PhotoSubjectId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Bounds") + .HasColumnType("longtext"); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("PhotoSubjectId"); + + b.HasIndex("UserId"); + + b.ToTable("PhotoSubjects"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Profiles.Comment", b => + { + b.Property("CommentId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Message") + .HasColumnType("longtext"); + + b.Property("PosterUserId") + .HasColumnType("int"); + + b.Property("TargetUserId") + .HasColumnType("int"); + + b.Property("ThumbsDown") + .HasColumnType("int"); + + b.Property("ThumbsUp") + .HasColumnType("int"); + + b.Property("Timestamp") + .HasColumnType("bigint"); + + b.HasKey("CommentId"); + + b.HasIndex("PosterUserId"); + + b.HasIndex("TargetUserId"); + + b.ToTable("Comments"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Profiles.LastMatch", b => + { + b.Property("UserId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Timestamp") + .HasColumnType("bigint"); + + b.HasKey("UserId"); + + b.ToTable("LastMatches"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Profiles.Location", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("X") + .HasColumnType("int"); + + b.Property("Y") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Locations"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Score", b => + { + b.Property("ScoreId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("PlayerIdCollection") + .HasColumnType("longtext"); + + b.Property("Points") + .HasColumnType("int"); + + b.Property("SlotId") + .HasColumnType("int"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("ScoreId"); + + b.HasIndex("SlotId"); + + b.ToTable("Scores"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Token", b => + { + b.Property("TokenId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("GameVersion") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("int"); + + b.Property("UserLocation") + .HasColumnType("longtext"); + + b.Property("UserToken") + .HasColumnType("longtext"); + + b.HasKey("TokenId"); + + b.ToTable("Tokens"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.User", b => + { + b.Property("UserId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Biography") + .HasColumnType("longtext"); + + b.Property("Game") + .HasColumnType("int"); + + b.Property("IconHash") + .HasColumnType("longtext"); + + b.Property("LocationId") + .HasColumnType("int"); + + b.Property("Password") + .HasColumnType("longtext"); + + b.Property("Pins") + .HasColumnType("longtext"); + + b.Property("PlanetHash") + .HasColumnType("longtext"); + + b.Property("Username") + .HasColumnType("longtext"); + + b.HasKey("UserId"); + + b.HasIndex("LocationId"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.HeartedProfile", b => + { + b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "HeartedUser") + .WithMany() + .HasForeignKey("HeartedUserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("HeartedUser"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Levels.HeartedLevel", 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.QueuedLevel", 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") + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Creator"); + + b.Navigation("Location"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Levels.VisitedLevel", 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") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Profiles.Comment", b => + { + b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "Poster") + .WithMany() + .HasForeignKey("PosterUserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "Target") + .WithMany() + .HasForeignKey("TargetUserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Poster"); + + b.Navigation("Target"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Score", b => + { + b.HasOne("LBPUnion.ProjectLighthouse.Types.Levels.Slot", "Slot") + .WithMany() + .HasForeignKey("SlotId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + 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"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/ProjectLighthouse/Migrations/20211120045239_AddPasswordToUser.cs b/ProjectLighthouse/Migrations/20211120045239_AddPasswordToUser.cs new file mode 100644 index 00000000..e962eee8 --- /dev/null +++ b/ProjectLighthouse/Migrations/20211120045239_AddPasswordToUser.cs @@ -0,0 +1,26 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace ProjectLighthouse.Migrations +{ + public partial class AddPasswordToUser : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "Password", + table: "Users", + type: "longtext", + nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Password", + table: "Users"); + } + } +} diff --git a/ProjectLighthouse/Migrations/DatabaseModelSnapshot.cs b/ProjectLighthouse/Migrations/DatabaseModelSnapshot.cs index 8f8c1454..c7ae61ec 100644 --- a/ProjectLighthouse/Migrations/DatabaseModelSnapshot.cs +++ b/ProjectLighthouse/Migrations/DatabaseModelSnapshot.cs @@ -451,6 +451,9 @@ namespace ProjectLighthouse.Migrations b.Property("LocationId") .HasColumnType("int"); + b.Property("Password") + .HasColumnType("longtext"); + b.Property("Pins") .HasColumnType("longtext"); diff --git a/ProjectLighthouse/Pages/ExternalAuth/LoginForm.cshtml b/ProjectLighthouse/Pages/ExternalAuth/LoginForm.cshtml index 38611a97..8f066355 100644 --- a/ProjectLighthouse/Pages/ExternalAuth/LoginForm.cshtml +++ b/ProjectLighthouse/Pages/ExternalAuth/LoginForm.cshtml @@ -4,8 +4,13 @@ @{ Layout = "Layouts/BaseLayout"; } +

Log in

-
-
-
+ +
+ + +
+ +
\ No newline at end of file diff --git a/ProjectLighthouse/Pages/ExternalAuth/LoginForm.cshtml.cs b/ProjectLighthouse/Pages/ExternalAuth/LoginForm.cshtml.cs index 56009d49..1e49ab0f 100644 --- a/ProjectLighthouse/Pages/ExternalAuth/LoginForm.cshtml.cs +++ b/ProjectLighthouse/Pages/ExternalAuth/LoginForm.cshtml.cs @@ -1,10 +1,39 @@ +#nullable enable +using System; +using System.Threading.Tasks; +using JetBrains.Annotations; using LBPUnion.ProjectLighthouse.Pages.Layouts; +using LBPUnion.ProjectLighthouse.Types; using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; namespace LBPUnion.ProjectLighthouse.Pages.ExternalAuth { public class LoginForm : BaseLayout { - public IActionResult OnGet() => this.Page(); + private readonly Database database; + + public LoginForm(Database database) + { + this.database = database; + } + + public bool WasLoginRequest { get; private set; } + + [UsedImplicitly] + public async Task OnGet([FromQuery] string username, [FromQuery] string password) + { + WasLoginRequest = !string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password); + + if (WasLoginRequest) + { + User? user = await this.database.Users.FirstOrDefaultAsync(u => u.Username == username); + if (user == null) return this.StatusCode(403, ""); + + Console.WriteLine(user.UserId); + } + + return this.Page(); + } } } \ No newline at end of file diff --git a/ProjectLighthouse/Pages/ExternalAuth/RegisterForm.cshtml b/ProjectLighthouse/Pages/ExternalAuth/RegisterForm.cshtml new file mode 100644 index 00000000..e3c012d7 --- /dev/null +++ b/ProjectLighthouse/Pages/ExternalAuth/RegisterForm.cshtml @@ -0,0 +1,20 @@ +@page "/register" +@model LBPUnion.ProjectLighthouse.Pages.ExternalAuth.RegisterForm + +@{ + Layout = "Layouts/BaseLayout"; +} + +

Register

+
+ +
+ + +
+ + +
+ +
+
\ No newline at end of file diff --git a/ProjectLighthouse/Pages/ExternalAuth/RegisterForm.cshtml.cs b/ProjectLighthouse/Pages/ExternalAuth/RegisterForm.cshtml.cs new file mode 100644 index 00000000..198dfeb2 --- /dev/null +++ b/ProjectLighthouse/Pages/ExternalAuth/RegisterForm.cshtml.cs @@ -0,0 +1,44 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Threading.Tasks; +using JetBrains.Annotations; +using LBPUnion.ProjectLighthouse.Helpers; +using LBPUnion.ProjectLighthouse.Pages.Layouts; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; + +namespace LBPUnion.ProjectLighthouse.Pages.ExternalAuth +{ + public class RegisterForm : BaseLayout + { + private readonly Database database; + + public RegisterForm(Database database) + { + this.database = database; + } + + public bool WasRegisterRequest { get; private set; } + + [UsedImplicitly] + [SuppressMessage("ReSharper", "SpecifyStringComparison")] + public async Task OnGet([FromQuery] string username, [FromQuery] string password, [FromQuery] string confirmPassword) + { + this.WasRegisterRequest = !string.IsNullOrEmpty(username) && + !string.IsNullOrEmpty(password) && + !string.IsNullOrEmpty(confirmPassword) && + password == confirmPassword; + + if (WasRegisterRequest) + { + Console.WriteLine(password); + bool userExists = await this.database.Users.FirstOrDefaultAsync(u => u.Username.ToLower() == username.ToLower()) != null; + if (userExists) return this.BadRequest(); + + this.database.CreateUser(username, HashHelper.BCryptHash(password)); + } + + return this.Page(); + } + } +} \ No newline at end of file diff --git a/ProjectLighthouse/Types/User.cs b/ProjectLighthouse/Types/User.cs index d872d2df..67e200c6 100644 --- a/ProjectLighthouse/Types/User.cs +++ b/ProjectLighthouse/Types/User.cs @@ -12,6 +12,7 @@ namespace LBPUnion.ProjectLighthouse.Types public readonly ClientsConnected ClientsConnected = new(); public int UserId { get; set; } public string Username { get; set; } + public string Password { get; set; } public string IconHash { get; set; } public int Game { get; set; } From bb4cecee2e23d497ae94945c5f0d80266400168f Mon Sep 17 00:00:00 2001 From: jvyden Date: Sat, 20 Nov 2021 00:13:11 -0500 Subject: [PATCH 007/123] Actually verify the password on login --- ProjectLighthouse/Pages/ExternalAuth/LoginForm.cshtml.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ProjectLighthouse/Pages/ExternalAuth/LoginForm.cshtml.cs b/ProjectLighthouse/Pages/ExternalAuth/LoginForm.cshtml.cs index 1e49ab0f..c49355ce 100644 --- a/ProjectLighthouse/Pages/ExternalAuth/LoginForm.cshtml.cs +++ b/ProjectLighthouse/Pages/ExternalAuth/LoginForm.cshtml.cs @@ -30,6 +30,8 @@ namespace LBPUnion.ProjectLighthouse.Pages.ExternalAuth User? user = await this.database.Users.FirstOrDefaultAsync(u => u.Username == username); if (user == null) return this.StatusCode(403, ""); + if (!BCrypt.Net.BCrypt.Verify(password, user.Password)) return this.StatusCode(403, ""); + Console.WriteLine(user.UserId); } From d11309b027fa5288bec75b44b2c92bcdb5df1a1f Mon Sep 17 00:00:00 2001 From: jvyden Date: Sat, 20 Nov 2021 00:27:39 -0500 Subject: [PATCH 008/123] Rename Token to GameToken --- .../Controllers/EnterLevelController.cs | 2 +- .../Controllers/FriendsController.cs | 6 +- .../Controllers/ListController.cs | 6 +- .../Controllers/LoginController.cs | 2 +- .../Controllers/MatchController.cs | 8 +- .../Controllers/PublishController.cs | 8 +- .../Controllers/ScoreController.cs | 6 +- .../Controllers/SlotsController.cs | 10 +- .../Controllers/UserController.cs | 4 +- ProjectLighthouse/Database.cs | 24 +- .../20211019021627_InitialCreate.Designer.cs | 2 +- .../20211019031221_HeartedLevels.Designer.cs | 2 +- .../20211019203627_LastMatches.Designer.cs | 2 +- .../20211020220840_ResourceList.Designer.cs | 2 +- .../20211026010814_FavouriteUsers.Designer.cs | 2 +- ...0211028015915_AddSlotTimestamp.Designer.cs | 2 +- ...lotFirstUploadedAndLastUpdated.Designer.cs | 2 +- ...29213334_RemoveUsedSlotsFromDb.Designer.cs | 2 +- ...20211030203837_AddMMPickToSlot.Designer.cs | 2 +- .../20211031234245_AddScoresTable.Designer.cs | 2 +- .../20211102215859_RenameTeamPick.Designer.cs | 2 +- ...194917_RemoveStartupMigrations.Designer.cs | 2 +- ...04031327_AddGameVersionToToken.Designer.cs | 2 +- ...04040509_AddGameVersionToSlots.Designer.cs | 2 +- ...20211104195812_AddPhotoSupport.Designer.cs | 2 +- ...PhotoSubjectToDoStuffWeirdName.Designer.cs | 2 +- ...39_DropPhotoSubjectParentPhoto.Designer.cs | 2 +- .../20211105205749_DropPhotoSlot.Designer.cs | 2 +- ...211106010424_AddCreatorToPhoto.Designer.cs | 2 +- ...452_NoPhotosByMeOrWithMeInUser.Designer.cs | 2 +- ...08013443_RemoveCommentsEnabled.Designer.cs | 2 +- .../20211108015422_AddPlaysToSlot.Designer.cs | 2 +- ...54552_RemoveCountsFromDatabase.Designer.cs | 2 +- ...8093616_GameSpecificPlayCounts.Designer.cs | 2 +- ...11108114052_VisitedLevelsTable.Designer.cs | 2 +- ...0211108212022_BooYayRateLevels.Designer.cs | 2 +- ...11109225543_AddLevelTypeToSlot.Designer.cs | 2 +- ...3091631_AddUserLocationToToken.Designer.cs | 2 +- ...3215128_VisitedLevelPlayCounts.Designer.cs | 2 +- ...06_VisitedLevelDropGameVersion.Designer.cs | 2 +- .../20211114231343_UserRefactor.Designer.cs | 2 +- ...erAddDefaultsToNullableStrings.Designer.cs | 2 +- ...1115052941_SlotAddLbpVitaPlays.Designer.cs | 2 +- ...211120045239_AddPasswordToUser.Designer.cs | 2 +- ...52549_RenameTokensToGameTokens.Designer.cs | 654 ++++++++++++++++++ ...20211120052549_RenameTokensToGameTokens.cs | 41 ++ .../Migrations/DatabaseModelSnapshot.cs | 46 +- .../Types/{Token.cs => GameToken.cs} | 2 +- 48 files changed, 791 insertions(+), 96 deletions(-) create mode 100644 ProjectLighthouse/Migrations/20211120052549_RenameTokensToGameTokens.Designer.cs create mode 100644 ProjectLighthouse/Migrations/20211120052549_RenameTokensToGameTokens.cs rename ProjectLighthouse/Types/{Token.cs => GameToken.cs} (93%) diff --git a/ProjectLighthouse/Controllers/EnterLevelController.cs b/ProjectLighthouse/Controllers/EnterLevelController.cs index fc46d90b..de4d4e0a 100644 --- a/ProjectLighthouse/Controllers/EnterLevelController.cs +++ b/ProjectLighthouse/Controllers/EnterLevelController.cs @@ -30,7 +30,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers Slot? slot = await this.database.Slots.FirstOrDefaultAsync(s => s.SlotId == slotId); if (slot == null) return this.StatusCode(403, ""); - Token? token = await this.database.TokenFromRequest(this.Request); + GameToken? token = await this.database.TokenFromRequest(this.Request); if (token == null) return this.StatusCode(403, ""); GameVersion gameVersion = token.GameVersion; diff --git a/ProjectLighthouse/Controllers/FriendsController.cs b/ProjectLighthouse/Controllers/FriendsController.cs index e4b2ef6a..34648a1b 100644 --- a/ProjectLighthouse/Controllers/FriendsController.cs +++ b/ProjectLighthouse/Controllers/FriendsController.cs @@ -69,13 +69,13 @@ namespace LBPUnion.ProjectLighthouse.Controllers [HttpGet("myFriends")] public async Task MyFriends() { - (User, Token)? userAndToken = await this.database.UserAndTokenFromRequest(this.Request); + (User, GameToken)? userAndToken = await this.database.UserAndTokenFromRequest(this.Request); if (userAndToken == null) return this.StatusCode(403, ""); // ReSharper disable once PossibleInvalidOperationException User user = userAndToken.Value.Item1; - Token token = userAndToken.Value.Item2; + GameToken gameToken = userAndToken.Value.Item2; if (!FriendHelper.FriendIdsByUserId.TryGetValue(user.UserId, out int[]? friendIds) || friendIds == null) { @@ -88,7 +88,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers User? friend = await this.database.Users.Include(u => u.Location).FirstOrDefaultAsync(u => u.UserId == friendId); if (friend == null) continue; - friends += friend.Serialize(token.GameVersion); + friends += friend.Serialize(gameToken.GameVersion); } return this.Ok(LbpSerializer.StringElement("myFriends", friends)); diff --git a/ProjectLighthouse/Controllers/ListController.cs b/ProjectLighthouse/Controllers/ListController.cs index f4139dc1..8c01c333 100644 --- a/ProjectLighthouse/Controllers/ListController.cs +++ b/ProjectLighthouse/Controllers/ListController.cs @@ -29,7 +29,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers [HttpGet("slots/lolcatftw/{username}")] public async Task GetLevelQueue(string username, [FromQuery] int pageSize, [FromQuery] int pageStart) { - Token? token = await this.database.TokenFromRequest(this.Request); + GameToken? token = await this.database.TokenFromRequest(this.Request); if (token == null) return this.StatusCode(403, ""); GameVersion gameVersion = token.GameVersion; @@ -110,7 +110,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers [HttpGet("favouriteSlots/{username}")] public async Task GetFavouriteSlots(string username, [FromQuery] int pageSize, [FromQuery] int pageStart) { - Token? token = await this.database.TokenFromRequest(this.Request); + GameToken? token = await this.database.TokenFromRequest(this.Request); if (token == null) return this.StatusCode(403, ""); GameVersion gameVersion = token.GameVersion; @@ -180,7 +180,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers [HttpGet("favouriteUsers/{username}")] public async Task GetFavouriteUsers(string username, [FromQuery] int pageSize, [FromQuery] int pageStart) { - Token? token = await this.database.TokenFromRequest(this.Request); + GameToken? token = await this.database.TokenFromRequest(this.Request); if (token == null) return this.StatusCode(403, ""); IEnumerable heartedProfiles = this.database.HeartedProfiles.Include diff --git a/ProjectLighthouse/Controllers/LoginController.cs b/ProjectLighthouse/Controllers/LoginController.cs index 6bce4863..a3384241 100644 --- a/ProjectLighthouse/Controllers/LoginController.cs +++ b/ProjectLighthouse/Controllers/LoginController.cs @@ -46,7 +46,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers string userLocation = ipAddress.ToString(); - Token? token = await this.database.AuthenticateUser(loginData, userLocation, titleId); + GameToken? token = await this.database.AuthenticateUser(loginData, userLocation, titleId); if (token == null) return this.StatusCode(403, ""); User? user = await this.database.UserFromToken(token); diff --git a/ProjectLighthouse/Controllers/MatchController.cs b/ProjectLighthouse/Controllers/MatchController.cs index 94f4fff5..ea448bba 100644 --- a/ProjectLighthouse/Controllers/MatchController.cs +++ b/ProjectLighthouse/Controllers/MatchController.cs @@ -32,13 +32,13 @@ namespace LBPUnion.ProjectLighthouse.Controllers [Produces("text/plain")] public async Task Match() { - (User, Token)? userAndToken = await this.database.UserAndTokenFromRequest(this.Request); + (User, GameToken)? userAndToken = await this.database.UserAndTokenFromRequest(this.Request); if (userAndToken == null) return this.StatusCode(403, ""); // ReSharper disable once PossibleInvalidOperationException User user = userAndToken.Value.Item1; - Token token = userAndToken.Value.Item2; + GameToken gameToken = userAndToken.Value.Item2; #region Parse match data @@ -97,7 +97,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers if (matchData is UpdateMyPlayerData playerData) { - MatchHelper.SetUserLocation(user.UserId, token.UserLocation); + MatchHelper.SetUserLocation(user.UserId, gameToken.UserLocation); Room? room = RoomHelper.FindRoomByUser(user, true); if (playerData.RoomState != null) @@ -108,7 +108,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers if (matchData is FindBestRoom && MatchHelper.UserLocations.Count > 1) { - FindBestRoomResponse? response = RoomHelper.FindBestRoom(user, token.UserLocation); + FindBestRoomResponse? response = RoomHelper.FindBestRoom(user, gameToken.UserLocation); if (response == null) return this.NotFound(); diff --git a/ProjectLighthouse/Controllers/PublishController.cs b/ProjectLighthouse/Controllers/PublishController.cs index d7094138..7ce1365c 100644 --- a/ProjectLighthouse/Controllers/PublishController.cs +++ b/ProjectLighthouse/Controllers/PublishController.cs @@ -66,13 +66,13 @@ namespace LBPUnion.ProjectLighthouse.Controllers public async Task Publish() { // User user = await this.database.UserFromRequest(this.Request); - (User, Token)? userAndToken = await this.database.UserAndTokenFromRequest(this.Request); + (User, GameToken)? userAndToken = await this.database.UserAndTokenFromRequest(this.Request); if (userAndToken == null) return this.StatusCode(403, ""); // ReSharper disable once PossibleInvalidOperationException User user = userAndToken.Value.Item1; - Token token = userAndToken.Value.Item2; + GameToken gameToken = userAndToken.Value.Item2; Slot? slot = await this.GetSlotFromBody(); if (slot == null || slot.Location == null) return this.BadRequest(); @@ -95,7 +95,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers slot.SlotId = oldSlot.SlotId; slot.FirstUploaded = oldSlot.FirstUploaded; slot.LastUpdated = TimeHelper.UnixTimeMilliseconds(); - slot.GameVersion = token.GameVersion; + slot.GameVersion = gameToken.GameVersion; this.database.Entry(oldSlot).CurrentValues.SetValues(slot); await this.database.SaveChangesAsync(); @@ -114,7 +114,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers slot.CreatorId = user.UserId; slot.FirstUploaded = TimeHelper.UnixTimeMilliseconds(); slot.LastUpdated = TimeHelper.UnixTimeMilliseconds(); - slot.GameVersion = token.GameVersion; + slot.GameVersion = gameToken.GameVersion; if (slot.MinimumPlayers == 0 || slot.MaximumPlayers == 0) { diff --git a/ProjectLighthouse/Controllers/ScoreController.cs b/ProjectLighthouse/Controllers/ScoreController.cs index 6f75e4d1..dc0762a8 100644 --- a/ProjectLighthouse/Controllers/ScoreController.cs +++ b/ProjectLighthouse/Controllers/ScoreController.cs @@ -28,13 +28,13 @@ namespace LBPUnion.ProjectLighthouse.Controllers [HttpPost("scoreboard/user/{id:int}")] public async Task SubmitScore(int id, [FromQuery] bool lbp1 = false, [FromQuery] bool lbp2 = false, [FromQuery] bool lbp3 = false) { - (User, Token)? userAndToken = await this.database.UserAndTokenFromRequest(this.Request); + (User, GameToken)? userAndToken = await this.database.UserAndTokenFromRequest(this.Request); if (userAndToken == null) return this.StatusCode(403, ""); // ReSharper disable once PossibleInvalidOperationException User user = userAndToken.Value.Item1; - Token token = userAndToken.Value.Item2; + GameToken gameToken = userAndToken.Value.Item2; this.Request.Body.Position = 0; string bodyString = await new StreamReader(this.Request.Body).ReadToEndAsync(); @@ -48,7 +48,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers Slot? slot = this.database.Slots.FirstOrDefault(s => s.SlotId == score.SlotId); if (slot == null) return this.BadRequest(); - switch (token.GameVersion) + switch (gameToken.GameVersion) { case GameVersion.LittleBigPlanet1: slot.PlaysLBP1Complete++; diff --git a/ProjectLighthouse/Controllers/SlotsController.cs b/ProjectLighthouse/Controllers/SlotsController.cs index 38a2f5c3..c0ee8d96 100644 --- a/ProjectLighthouse/Controllers/SlotsController.cs +++ b/ProjectLighthouse/Controllers/SlotsController.cs @@ -26,7 +26,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers [HttpGet("slots/by")] public async Task SlotsBy([FromQuery] string u, [FromQuery] int pageStart, [FromQuery] int pageSize) { - Token? token = await this.database.TokenFromRequest(this.Request); + GameToken? token = await this.database.TokenFromRequest(this.Request); if (token == null) return this.StatusCode(403, ""); GameVersion gameVersion = token.GameVersion; @@ -71,7 +71,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers User? user = await this.database.UserFromRequest(this.Request); if (user == null) return this.StatusCode(403, ""); - Token? token = await this.database.TokenFromRequest(this.Request); + GameToken? token = await this.database.TokenFromRequest(this.Request); if (token == null) return this.StatusCode(403, ""); GameVersion gameVersion = token.GameVersion; @@ -95,7 +95,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers [HttpGet("slots")] public async Task NewestSlots([FromQuery] int pageStart, [FromQuery] int pageSize) { - Token? token = await this.database.TokenFromRequest(this.Request); + GameToken? token = await this.database.TokenFromRequest(this.Request); if (token == null) return this.StatusCode(403, ""); GameVersion gameVersion = token.GameVersion; @@ -114,7 +114,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers [HttpGet("slots/mmpicks")] public async Task TeamPickedSlots([FromQuery] int pageStart, [FromQuery] int pageSize) { - Token? token = await this.database.TokenFromRequest(this.Request); + GameToken? token = await this.database.TokenFromRequest(this.Request); if (token == null) return this.StatusCode(403, ""); GameVersion gameVersion = token.GameVersion; @@ -134,7 +134,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers [HttpGet("slots/lbp2luckydip")] public async Task LuckyDipSlots([FromQuery] int pageStart, [FromQuery] int pageSize, [FromQuery] int seed) { - Token? token = await this.database.TokenFromRequest(this.Request); + GameToken? token = await this.database.TokenFromRequest(this.Request); if (token == null) return this.StatusCode(403, ""); GameVersion gameVersion = token.GameVersion; diff --git a/ProjectLighthouse/Controllers/UserController.cs b/ProjectLighthouse/Controllers/UserController.cs index 0c787e74..e5badad5 100644 --- a/ProjectLighthouse/Controllers/UserController.cs +++ b/ProjectLighthouse/Controllers/UserController.cs @@ -35,7 +35,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers [HttpGet("user/{username}")] public async Task GetUser(string username) { - Token? token = await this.database.TokenFromRequest(this.Request); + GameToken? token = await this.database.TokenFromRequest(this.Request); if (token == null) return this.StatusCode(403, ""); string? user = await this.GetSerializedUser(username, token.GameVersion); @@ -47,7 +47,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers [HttpGet("users")] public async Task GetUserAlt([FromQuery] string[] u) { - Token? token = await this.database.TokenFromRequest(this.Request); + GameToken? token = await this.database.TokenFromRequest(this.Request); if (token == null) return this.StatusCode(403, ""); List serializedUsers = new(); diff --git a/ProjectLighthouse/Database.cs b/ProjectLighthouse/Database.cs index 5b1c7253..e71ca13b 100644 --- a/ProjectLighthouse/Database.cs +++ b/ProjectLighthouse/Database.cs @@ -22,7 +22,7 @@ namespace LBPUnion.ProjectLighthouse public DbSet HeartedLevels { get; set; } public DbSet HeartedProfiles { get; set; } public DbSet Comments { get; set; } - public DbSet Tokens { get; set; } + public DbSet GameTokens { get; set; } public DbSet Scores { get; set; } public DbSet PhotoSubjects { get; set; } public DbSet Photos { get; set; } @@ -59,13 +59,13 @@ namespace LBPUnion.ProjectLighthouse } #nullable enable - public async Task AuthenticateUser(LoginData loginData, string userLocation, string titleId = "") + public async Task AuthenticateUser(LoginData loginData, string userLocation, string titleId = "") { // TODO: don't use psn name to authenticate User? user = await this.Users.FirstOrDefaultAsync(u => u.Username == loginData.Username); if (user == null) return null; - Token token = new() + GameToken gameToken = new() { UserToken = HashHelper.GenerateAuthToken(), UserId = user.UserId, @@ -73,27 +73,27 @@ namespace LBPUnion.ProjectLighthouse GameVersion = GameVersionHelper.FromTitleId(titleId), }; - if (token.GameVersion == GameVersion.Unknown) + if (gameToken.GameVersion == GameVersion.Unknown) { Logger.Log($"Unknown GameVersion for TitleId {titleId}", LoggerLevelLogin.Instance); return null; } - this.Tokens.Add(token); + this.GameTokens.Add(gameToken); await this.SaveChangesAsync(); - return token; + return gameToken; } public async Task UserFromAuthToken(string authToken) { - Token? token = await this.Tokens.FirstOrDefaultAsync(t => t.UserToken == authToken); + GameToken? token = await this.GameTokens.FirstOrDefaultAsync(t => t.UserToken == authToken); if (token == null) return null; return await this.Users.Include(u => u.Location).FirstOrDefaultAsync(u => u.UserId == token.UserId); } - public async Task UserFromToken(Token token) => await this.UserFromAuthToken(token.UserToken); + public async Task UserFromToken(GameToken gameToken) => await this.UserFromAuthToken(gameToken.UserToken); public async Task UserFromRequest(HttpRequest request) { @@ -102,18 +102,18 @@ namespace LBPUnion.ProjectLighthouse return await this.UserFromAuthToken(mmAuth); } - public async Task TokenFromRequest(HttpRequest request) + public async Task TokenFromRequest(HttpRequest request) { if (!request.Cookies.TryGetValue("MM_AUTH", out string? mmAuth) || mmAuth == null) return null; - return await this.Tokens.FirstOrDefaultAsync(t => t.UserToken == mmAuth); + return await this.GameTokens.FirstOrDefaultAsync(t => t.UserToken == mmAuth); } - public async Task<(User, Token)?> UserAndTokenFromRequest(HttpRequest request) + public async Task<(User, GameToken)?> UserAndTokenFromRequest(HttpRequest request) { if (!request.Cookies.TryGetValue("MM_AUTH", out string? mmAuth) || mmAuth == null) return null; - Token? token = await this.Tokens.FirstOrDefaultAsync(t => t.UserToken == mmAuth); + GameToken? token = await this.GameTokens.FirstOrDefaultAsync(t => t.UserToken == mmAuth); if (token == null) return null; User? user = await this.UserFromToken(token); diff --git a/ProjectLighthouse/Migrations/20211019021627_InitialCreate.Designer.cs b/ProjectLighthouse/Migrations/20211019021627_InitialCreate.Designer.cs index 7fcae3a9..053a8eee 100644 --- a/ProjectLighthouse/Migrations/20211019021627_InitialCreate.Designer.cs +++ b/ProjectLighthouse/Migrations/20211019021627_InitialCreate.Designer.cs @@ -154,7 +154,7 @@ namespace ProjectLighthouse.Migrations b.ToTable("Slots"); }); - modelBuilder.Entity("ProjectLighthouse.Types.Token", b => + modelBuilder.Entity("ProjectLighthouse.Types.GameToken", b => { b.Property("TokenId") .ValueGeneratedOnAdd() diff --git a/ProjectLighthouse/Migrations/20211019031221_HeartedLevels.Designer.cs b/ProjectLighthouse/Migrations/20211019031221_HeartedLevels.Designer.cs index d531cf75..43af2c8a 100644 --- a/ProjectLighthouse/Migrations/20211019031221_HeartedLevels.Designer.cs +++ b/ProjectLighthouse/Migrations/20211019031221_HeartedLevels.Designer.cs @@ -175,7 +175,7 @@ namespace ProjectLighthouse.Migrations b.ToTable("Slots"); }); - modelBuilder.Entity("ProjectLighthouse.Types.Token", b => + modelBuilder.Entity("ProjectLighthouse.Types.GameToken", b => { b.Property("TokenId") .ValueGeneratedOnAdd() diff --git a/ProjectLighthouse/Migrations/20211019203627_LastMatches.Designer.cs b/ProjectLighthouse/Migrations/20211019203627_LastMatches.Designer.cs index aebb0f62..03647fc8 100644 --- a/ProjectLighthouse/Migrations/20211019203627_LastMatches.Designer.cs +++ b/ProjectLighthouse/Migrations/20211019203627_LastMatches.Designer.cs @@ -189,7 +189,7 @@ namespace ProjectLighthouse.Migrations b.ToTable("Slots"); }); - modelBuilder.Entity("ProjectLighthouse.Types.Token", b => + modelBuilder.Entity("ProjectLighthouse.Types.GameToken", b => { b.Property("TokenId") .ValueGeneratedOnAdd() diff --git a/ProjectLighthouse/Migrations/20211020220840_ResourceList.Designer.cs b/ProjectLighthouse/Migrations/20211020220840_ResourceList.Designer.cs index 36a02088..11880c79 100644 --- a/ProjectLighthouse/Migrations/20211020220840_ResourceList.Designer.cs +++ b/ProjectLighthouse/Migrations/20211020220840_ResourceList.Designer.cs @@ -189,7 +189,7 @@ namespace ProjectLighthouse.Migrations b.ToTable("Slots"); }); - modelBuilder.Entity("ProjectLighthouse.Types.Token", b => + modelBuilder.Entity("ProjectLighthouse.Types.GameToken", b => { b.Property("TokenId") .ValueGeneratedOnAdd() diff --git a/ProjectLighthouse/Migrations/20211026010814_FavouriteUsers.Designer.cs b/ProjectLighthouse/Migrations/20211026010814_FavouriteUsers.Designer.cs index 5c292a1e..5f0ff875 100644 --- a/ProjectLighthouse/Migrations/20211026010814_FavouriteUsers.Designer.cs +++ b/ProjectLighthouse/Migrations/20211026010814_FavouriteUsers.Designer.cs @@ -208,7 +208,7 @@ namespace ProjectLighthouse.Migrations b.ToTable("Locations"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Token", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.GameToken", b => { b.Property("TokenId") .ValueGeneratedOnAdd() diff --git a/ProjectLighthouse/Migrations/20211028015915_AddSlotTimestamp.Designer.cs b/ProjectLighthouse/Migrations/20211028015915_AddSlotTimestamp.Designer.cs index 48beed7d..09a0a521 100644 --- a/ProjectLighthouse/Migrations/20211028015915_AddSlotTimestamp.Designer.cs +++ b/ProjectLighthouse/Migrations/20211028015915_AddSlotTimestamp.Designer.cs @@ -211,7 +211,7 @@ namespace ProjectLighthouse.Migrations b.ToTable("Locations"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Token", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.GameToken", b => { b.Property("TokenId") .ValueGeneratedOnAdd() diff --git a/ProjectLighthouse/Migrations/20211028021513_AddSlotFirstUploadedAndLastUpdated.Designer.cs b/ProjectLighthouse/Migrations/20211028021513_AddSlotFirstUploadedAndLastUpdated.Designer.cs index d1ba6622..3cf2e85b 100644 --- a/ProjectLighthouse/Migrations/20211028021513_AddSlotFirstUploadedAndLastUpdated.Designer.cs +++ b/ProjectLighthouse/Migrations/20211028021513_AddSlotFirstUploadedAndLastUpdated.Designer.cs @@ -214,7 +214,7 @@ namespace ProjectLighthouse.Migrations b.ToTable("Locations"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Token", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.GameToken", b => { b.Property("TokenId") .ValueGeneratedOnAdd() diff --git a/ProjectLighthouse/Migrations/20211029213334_RemoveUsedSlotsFromDb.Designer.cs b/ProjectLighthouse/Migrations/20211029213334_RemoveUsedSlotsFromDb.Designer.cs index 59a0dcc7..ef52f9e7 100644 --- a/ProjectLighthouse/Migrations/20211029213334_RemoveUsedSlotsFromDb.Designer.cs +++ b/ProjectLighthouse/Migrations/20211029213334_RemoveUsedSlotsFromDb.Designer.cs @@ -214,7 +214,7 @@ namespace ProjectLighthouse.Migrations b.ToTable("Locations"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Token", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.GameToken", b => { b.Property("TokenId") .ValueGeneratedOnAdd() diff --git a/ProjectLighthouse/Migrations/20211030203837_AddMMPickToSlot.Designer.cs b/ProjectLighthouse/Migrations/20211030203837_AddMMPickToSlot.Designer.cs index f9f84485..eeca745a 100644 --- a/ProjectLighthouse/Migrations/20211030203837_AddMMPickToSlot.Designer.cs +++ b/ProjectLighthouse/Migrations/20211030203837_AddMMPickToSlot.Designer.cs @@ -217,7 +217,7 @@ namespace ProjectLighthouse.Migrations b.ToTable("Locations"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Token", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.GameToken", b => { b.Property("TokenId") .ValueGeneratedOnAdd() diff --git a/ProjectLighthouse/Migrations/20211031234245_AddScoresTable.Designer.cs b/ProjectLighthouse/Migrations/20211031234245_AddScoresTable.Designer.cs index ce6e6792..14211110 100644 --- a/ProjectLighthouse/Migrations/20211031234245_AddScoresTable.Designer.cs +++ b/ProjectLighthouse/Migrations/20211031234245_AddScoresTable.Designer.cs @@ -242,7 +242,7 @@ namespace ProjectLighthouse.Migrations b.ToTable("Scores"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Token", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.GameToken", b => { b.Property("TokenId") .ValueGeneratedOnAdd() diff --git a/ProjectLighthouse/Migrations/20211102215859_RenameTeamPick.Designer.cs b/ProjectLighthouse/Migrations/20211102215859_RenameTeamPick.Designer.cs index 34087d12..131c53ad 100644 --- a/ProjectLighthouse/Migrations/20211102215859_RenameTeamPick.Designer.cs +++ b/ProjectLighthouse/Migrations/20211102215859_RenameTeamPick.Designer.cs @@ -242,7 +242,7 @@ namespace ProjectLighthouse.Migrations b.ToTable("Scores"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Token", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.GameToken", b => { b.Property("TokenId") .ValueGeneratedOnAdd() diff --git a/ProjectLighthouse/Migrations/20211103194917_RemoveStartupMigrations.Designer.cs b/ProjectLighthouse/Migrations/20211103194917_RemoveStartupMigrations.Designer.cs index f26e5451..ce336fce 100644 --- a/ProjectLighthouse/Migrations/20211103194917_RemoveStartupMigrations.Designer.cs +++ b/ProjectLighthouse/Migrations/20211103194917_RemoveStartupMigrations.Designer.cs @@ -242,7 +242,7 @@ namespace ProjectLighthouse.Migrations b.ToTable("Scores"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Token", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.GameToken", b => { b.Property("TokenId") .ValueGeneratedOnAdd() diff --git a/ProjectLighthouse/Migrations/20211104031327_AddGameVersionToToken.Designer.cs b/ProjectLighthouse/Migrations/20211104031327_AddGameVersionToToken.Designer.cs index 9814b171..215e0608 100644 --- a/ProjectLighthouse/Migrations/20211104031327_AddGameVersionToToken.Designer.cs +++ b/ProjectLighthouse/Migrations/20211104031327_AddGameVersionToToken.Designer.cs @@ -242,7 +242,7 @@ namespace ProjectLighthouse.Migrations b.ToTable("Scores"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Token", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.GameToken", b => { b.Property("TokenId") .ValueGeneratedOnAdd() diff --git a/ProjectLighthouse/Migrations/20211104040509_AddGameVersionToSlots.Designer.cs b/ProjectLighthouse/Migrations/20211104040509_AddGameVersionToSlots.Designer.cs index 0727a0e5..94070a76 100644 --- a/ProjectLighthouse/Migrations/20211104040509_AddGameVersionToSlots.Designer.cs +++ b/ProjectLighthouse/Migrations/20211104040509_AddGameVersionToSlots.Designer.cs @@ -245,7 +245,7 @@ namespace ProjectLighthouse.Migrations b.ToTable("Scores"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Token", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.GameToken", b => { b.Property("TokenId") .ValueGeneratedOnAdd() diff --git a/ProjectLighthouse/Migrations/20211104195812_AddPhotoSupport.Designer.cs b/ProjectLighthouse/Migrations/20211104195812_AddPhotoSupport.Designer.cs index b848597f..8e738f6a 100644 --- a/ProjectLighthouse/Migrations/20211104195812_AddPhotoSupport.Designer.cs +++ b/ProjectLighthouse/Migrations/20211104195812_AddPhotoSupport.Designer.cs @@ -293,7 +293,7 @@ namespace ProjectLighthouse.Migrations b.ToTable("Scores"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Token", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.GameToken", b => { b.Property("TokenId") .ValueGeneratedOnAdd() diff --git a/ProjectLighthouse/Migrations/20211105205010_UpdatePhotoAndPhotoSubjectToDoStuffWeirdName.Designer.cs b/ProjectLighthouse/Migrations/20211105205010_UpdatePhotoAndPhotoSubjectToDoStuffWeirdName.Designer.cs index 9dee3007..31f84ecc 100644 --- a/ProjectLighthouse/Migrations/20211105205010_UpdatePhotoAndPhotoSubjectToDoStuffWeirdName.Designer.cs +++ b/ProjectLighthouse/Migrations/20211105205010_UpdatePhotoAndPhotoSubjectToDoStuffWeirdName.Designer.cs @@ -303,7 +303,7 @@ namespace ProjectLighthouse.Migrations b.ToTable("Scores"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Token", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.GameToken", b => { b.Property("TokenId") .ValueGeneratedOnAdd() diff --git a/ProjectLighthouse/Migrations/20211105205239_DropPhotoSubjectParentPhoto.Designer.cs b/ProjectLighthouse/Migrations/20211105205239_DropPhotoSubjectParentPhoto.Designer.cs index 5f463653..7ee30fe0 100644 --- a/ProjectLighthouse/Migrations/20211105205239_DropPhotoSubjectParentPhoto.Designer.cs +++ b/ProjectLighthouse/Migrations/20211105205239_DropPhotoSubjectParentPhoto.Designer.cs @@ -298,7 +298,7 @@ namespace ProjectLighthouse.Migrations b.ToTable("Scores"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Token", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.GameToken", b => { b.Property("TokenId") .ValueGeneratedOnAdd() diff --git a/ProjectLighthouse/Migrations/20211105205749_DropPhotoSlot.Designer.cs b/ProjectLighthouse/Migrations/20211105205749_DropPhotoSlot.Designer.cs index 9cb364e3..9d153964 100644 --- a/ProjectLighthouse/Migrations/20211105205749_DropPhotoSlot.Designer.cs +++ b/ProjectLighthouse/Migrations/20211105205749_DropPhotoSlot.Designer.cs @@ -293,7 +293,7 @@ namespace ProjectLighthouse.Migrations b.ToTable("Scores"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Token", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.GameToken", b => { b.Property("TokenId") .ValueGeneratedOnAdd() diff --git a/ProjectLighthouse/Migrations/20211106010424_AddCreatorToPhoto.Designer.cs b/ProjectLighthouse/Migrations/20211106010424_AddCreatorToPhoto.Designer.cs index dfaa00d8..a1804945 100644 --- a/ProjectLighthouse/Migrations/20211106010424_AddCreatorToPhoto.Designer.cs +++ b/ProjectLighthouse/Migrations/20211106010424_AddCreatorToPhoto.Designer.cs @@ -298,7 +298,7 @@ namespace ProjectLighthouse.Migrations b.ToTable("Scores"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Token", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.GameToken", b => { b.Property("TokenId") .ValueGeneratedOnAdd() diff --git a/ProjectLighthouse/Migrations/20211107023452_NoPhotosByMeOrWithMeInUser.Designer.cs b/ProjectLighthouse/Migrations/20211107023452_NoPhotosByMeOrWithMeInUser.Designer.cs index 46f8d20f..22841820 100644 --- a/ProjectLighthouse/Migrations/20211107023452_NoPhotosByMeOrWithMeInUser.Designer.cs +++ b/ProjectLighthouse/Migrations/20211107023452_NoPhotosByMeOrWithMeInUser.Designer.cs @@ -303,7 +303,7 @@ namespace ProjectLighthouse.Migrations b.ToTable("Scores"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Token", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.GameToken", b => { b.Property("TokenId") .ValueGeneratedOnAdd() diff --git a/ProjectLighthouse/Migrations/20211108013443_RemoveCommentsEnabled.Designer.cs b/ProjectLighthouse/Migrations/20211108013443_RemoveCommentsEnabled.Designer.cs index 67842c32..89324073 100644 --- a/ProjectLighthouse/Migrations/20211108013443_RemoveCommentsEnabled.Designer.cs +++ b/ProjectLighthouse/Migrations/20211108013443_RemoveCommentsEnabled.Designer.cs @@ -303,7 +303,7 @@ namespace ProjectLighthouse.Migrations b.ToTable("Scores"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Token", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.GameToken", b => { b.Property("TokenId") .ValueGeneratedOnAdd() diff --git a/ProjectLighthouse/Migrations/20211108015422_AddPlaysToSlot.Designer.cs b/ProjectLighthouse/Migrations/20211108015422_AddPlaysToSlot.Designer.cs index 40001bd0..59bcc054 100644 --- a/ProjectLighthouse/Migrations/20211108015422_AddPlaysToSlot.Designer.cs +++ b/ProjectLighthouse/Migrations/20211108015422_AddPlaysToSlot.Designer.cs @@ -306,7 +306,7 @@ namespace ProjectLighthouse.Migrations b.ToTable("Scores"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Token", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.GameToken", b => { b.Property("TokenId") .ValueGeneratedOnAdd() diff --git a/ProjectLighthouse/Migrations/20211108054552_RemoveCountsFromDatabase.Designer.cs b/ProjectLighthouse/Migrations/20211108054552_RemoveCountsFromDatabase.Designer.cs index 4d2d382f..30993275 100644 --- a/ProjectLighthouse/Migrations/20211108054552_RemoveCountsFromDatabase.Designer.cs +++ b/ProjectLighthouse/Migrations/20211108054552_RemoveCountsFromDatabase.Designer.cs @@ -306,7 +306,7 @@ namespace ProjectLighthouse.Migrations b.ToTable("Scores"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Token", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.GameToken", b => { b.Property("TokenId") .ValueGeneratedOnAdd() diff --git a/ProjectLighthouse/Migrations/20211108093616_GameSpecificPlayCounts.Designer.cs b/ProjectLighthouse/Migrations/20211108093616_GameSpecificPlayCounts.Designer.cs index abf45882..c649e759 100644 --- a/ProjectLighthouse/Migrations/20211108093616_GameSpecificPlayCounts.Designer.cs +++ b/ProjectLighthouse/Migrations/20211108093616_GameSpecificPlayCounts.Designer.cs @@ -330,7 +330,7 @@ namespace ProjectLighthouse.Migrations b.ToTable("Scores"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Token", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.GameToken", b => { b.Property("TokenId") .ValueGeneratedOnAdd() diff --git a/ProjectLighthouse/Migrations/20211108114052_VisitedLevelsTable.Designer.cs b/ProjectLighthouse/Migrations/20211108114052_VisitedLevelsTable.Designer.cs index f78f1d58..9ea4167f 100644 --- a/ProjectLighthouse/Migrations/20211108114052_VisitedLevelsTable.Designer.cs +++ b/ProjectLighthouse/Migrations/20211108114052_VisitedLevelsTable.Designer.cs @@ -354,7 +354,7 @@ namespace ProjectLighthouse.Migrations b.ToTable("Scores"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Token", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.GameToken", b => { b.Property("TokenId") .ValueGeneratedOnAdd() diff --git a/ProjectLighthouse/Migrations/20211108212022_BooYayRateLevels.Designer.cs b/ProjectLighthouse/Migrations/20211108212022_BooYayRateLevels.Designer.cs index 4d1d9dbf..fc982fdc 100644 --- a/ProjectLighthouse/Migrations/20211108212022_BooYayRateLevels.Designer.cs +++ b/ProjectLighthouse/Migrations/20211108212022_BooYayRateLevels.Designer.cs @@ -381,7 +381,7 @@ namespace ProjectLighthouse.Migrations b.ToTable("Scores"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Token", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.GameToken", b => { b.Property("TokenId") .ValueGeneratedOnAdd() diff --git a/ProjectLighthouse/Migrations/20211109225543_AddLevelTypeToSlot.Designer.cs b/ProjectLighthouse/Migrations/20211109225543_AddLevelTypeToSlot.Designer.cs index cc243392..f14eb761 100644 --- a/ProjectLighthouse/Migrations/20211109225543_AddLevelTypeToSlot.Designer.cs +++ b/ProjectLighthouse/Migrations/20211109225543_AddLevelTypeToSlot.Designer.cs @@ -384,7 +384,7 @@ namespace ProjectLighthouse.Migrations b.ToTable("Scores"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Token", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.GameToken", b => { b.Property("TokenId") .ValueGeneratedOnAdd() diff --git a/ProjectLighthouse/Migrations/20211113091631_AddUserLocationToToken.Designer.cs b/ProjectLighthouse/Migrations/20211113091631_AddUserLocationToToken.Designer.cs index 76be44ce..02bde039 100644 --- a/ProjectLighthouse/Migrations/20211113091631_AddUserLocationToToken.Designer.cs +++ b/ProjectLighthouse/Migrations/20211113091631_AddUserLocationToToken.Designer.cs @@ -384,7 +384,7 @@ namespace ProjectLighthouse.Migrations b.ToTable("Scores"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Token", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.GameToken", b => { b.Property("TokenId") .ValueGeneratedOnAdd() diff --git a/ProjectLighthouse/Migrations/20211113215128_VisitedLevelPlayCounts.Designer.cs b/ProjectLighthouse/Migrations/20211113215128_VisitedLevelPlayCounts.Designer.cs index 5d93e5a2..8385d1da 100644 --- a/ProjectLighthouse/Migrations/20211113215128_VisitedLevelPlayCounts.Designer.cs +++ b/ProjectLighthouse/Migrations/20211113215128_VisitedLevelPlayCounts.Designer.cs @@ -401,7 +401,7 @@ namespace ProjectLighthouse.Migrations b.ToTable("Scores"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Token", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.GameToken", b => { b.Property("TokenId") .ValueGeneratedOnAdd() diff --git a/ProjectLighthouse/Migrations/20211113220306_VisitedLevelDropGameVersion.Designer.cs b/ProjectLighthouse/Migrations/20211113220306_VisitedLevelDropGameVersion.Designer.cs index b48129af..38304f22 100644 --- a/ProjectLighthouse/Migrations/20211113220306_VisitedLevelDropGameVersion.Designer.cs +++ b/ProjectLighthouse/Migrations/20211113220306_VisitedLevelDropGameVersion.Designer.cs @@ -398,7 +398,7 @@ namespace ProjectLighthouse.Migrations b.ToTable("Scores"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Token", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.GameToken", b => { b.Property("TokenId") .ValueGeneratedOnAdd() diff --git a/ProjectLighthouse/Migrations/20211114231343_UserRefactor.Designer.cs b/ProjectLighthouse/Migrations/20211114231343_UserRefactor.Designer.cs index cf70b3b0..49a61ffa 100644 --- a/ProjectLighthouse/Migrations/20211114231343_UserRefactor.Designer.cs +++ b/ProjectLighthouse/Migrations/20211114231343_UserRefactor.Designer.cs @@ -384,7 +384,7 @@ namespace ProjectLighthouse.Migrations b.ToTable("Scores"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Token", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.GameToken", b => { b.Property("TokenId") .ValueGeneratedOnAdd() diff --git a/ProjectLighthouse/Migrations/20211115050553_UserAddDefaultsToNullableStrings.Designer.cs b/ProjectLighthouse/Migrations/20211115050553_UserAddDefaultsToNullableStrings.Designer.cs index 556eb96f..3aad3cc8 100644 --- a/ProjectLighthouse/Migrations/20211115050553_UserAddDefaultsToNullableStrings.Designer.cs +++ b/ProjectLighthouse/Migrations/20211115050553_UserAddDefaultsToNullableStrings.Designer.cs @@ -400,7 +400,7 @@ namespace ProjectLighthouse.Migrations b.ToTable("Scores"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Token", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.GameToken", b => { b.Property("TokenId") .ValueGeneratedOnAdd() diff --git a/ProjectLighthouse/Migrations/20211115052941_SlotAddLbpVitaPlays.Designer.cs b/ProjectLighthouse/Migrations/20211115052941_SlotAddLbpVitaPlays.Designer.cs index efb62ea6..d3531618 100644 --- a/ProjectLighthouse/Migrations/20211115052941_SlotAddLbpVitaPlays.Designer.cs +++ b/ProjectLighthouse/Migrations/20211115052941_SlotAddLbpVitaPlays.Designer.cs @@ -412,7 +412,7 @@ namespace ProjectLighthouse.Migrations b.ToTable("Scores"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Token", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.GameToken", b => { b.Property("TokenId") .ValueGeneratedOnAdd() diff --git a/ProjectLighthouse/Migrations/20211120045239_AddPasswordToUser.Designer.cs b/ProjectLighthouse/Migrations/20211120045239_AddPasswordToUser.Designer.cs index 2f2f2a57..1afd4976 100644 --- a/ProjectLighthouse/Migrations/20211120045239_AddPasswordToUser.Designer.cs +++ b/ProjectLighthouse/Migrations/20211120045239_AddPasswordToUser.Designer.cs @@ -412,7 +412,7 @@ namespace ProjectLighthouse.Migrations b.ToTable("Scores"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Token", b => + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.GameToken", b => { b.Property("TokenId") .ValueGeneratedOnAdd() diff --git a/ProjectLighthouse/Migrations/20211120052549_RenameTokensToGameTokens.Designer.cs b/ProjectLighthouse/Migrations/20211120052549_RenameTokensToGameTokens.Designer.cs new file mode 100644 index 00000000..f0e1ea83 --- /dev/null +++ b/ProjectLighthouse/Migrations/20211120052549_RenameTokensToGameTokens.Designer.cs @@ -0,0 +1,654 @@ +// +using LBPUnion.ProjectLighthouse; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace ProjectLighthouse.Migrations +{ + [DbContext(typeof(Database))] + [Migration("20211120052549_RenameTokensToGameTokens")] + partial class RenameTokensToGameTokens + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.GameToken", b => + { + b.Property("TokenId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("GameVersion") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("int"); + + b.Property("UserLocation") + .HasColumnType("longtext"); + + b.Property("UserToken") + .HasColumnType("longtext"); + + b.HasKey("TokenId"); + + 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 => + { + b.Property("HeartedLevelId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("SlotId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("HeartedLevelId"); + + b.HasIndex("SlotId"); + + b.HasIndex("UserId"); + + b.ToTable("HeartedLevels"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Levels.QueuedLevel", b => + { + b.Property("QueuedLevelId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("SlotId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("QueuedLevelId"); + + b.HasIndex("SlotId"); + + b.HasIndex("UserId"); + + b.ToTable("QueuedLevels"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Levels.RatedLevel", b => + { + b.Property("RatedLevelId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Rating") + .HasColumnType("int"); + + b.Property("RatingLBP1") + .HasColumnType("double"); + + b.Property("SlotId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("RatedLevelId"); + + b.HasIndex("SlotId"); + + b.HasIndex("UserId"); + + b.ToTable("RatedLevels"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Levels.Slot", b => + { + b.Property("SlotId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("AuthorLabels") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("BackgroundHash") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CreatorId") + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FirstUploaded") + .HasColumnType("bigint"); + + b.Property("GameVersion") + .HasColumnType("int"); + + b.Property("IconHash") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("InitiallyLocked") + .HasColumnType("tinyint(1)"); + + b.Property("LastUpdated") + .HasColumnType("bigint"); + + b.Property("Lbp1Only") + .HasColumnType("tinyint(1)"); + + b.Property("LevelType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("LocationId") + .HasColumnType("int"); + + b.Property("MaximumPlayers") + .HasColumnType("int"); + + b.Property("MinimumPlayers") + .HasColumnType("int"); + + b.Property("MoveRequired") + .HasColumnType("tinyint(1)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PlaysLBP1") + .HasColumnType("int"); + + b.Property("PlaysLBP1Complete") + .HasColumnType("int"); + + b.Property("PlaysLBP1Unique") + .HasColumnType("int"); + + b.Property("PlaysLBP2") + .HasColumnType("int"); + + b.Property("PlaysLBP2Complete") + .HasColumnType("int"); + + b.Property("PlaysLBP2Unique") + .HasColumnType("int"); + + b.Property("PlaysLBP3") + .HasColumnType("int"); + + b.Property("PlaysLBP3Complete") + .HasColumnType("int"); + + b.Property("PlaysLBP3Unique") + .HasColumnType("int"); + + b.Property("PlaysLBPVita") + .HasColumnType("int"); + + b.Property("PlaysLBPVitaComplete") + .HasColumnType("int"); + + b.Property("PlaysLBPVitaUnique") + .HasColumnType("int"); + + b.Property("ResourceCollection") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("RootLevel") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Shareable") + .HasColumnType("int"); + + b.Property("SubLevel") + .HasColumnType("tinyint(1)"); + + b.Property("TeamPick") + .HasColumnType("tinyint(1)"); + + b.HasKey("SlotId"); + + b.HasIndex("CreatorId"); + + b.HasIndex("LocationId"); + + b.ToTable("Slots"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Levels.VisitedLevel", b => + { + b.Property("VisitedLevelId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("PlaysLBP1") + .HasColumnType("int"); + + b.Property("PlaysLBP2") + .HasColumnType("int"); + + b.Property("PlaysLBP3") + .HasColumnType("int"); + + b.Property("PlaysLBPVita") + .HasColumnType("int"); + + b.Property("SlotId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("VisitedLevelId"); + + b.HasIndex("SlotId"); + + b.HasIndex("UserId"); + + b.ToTable("VisitedLevels"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Photo", b => + { + b.Property("PhotoId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("CreatorId") + .HasColumnType("int"); + + b.Property("LargeHash") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MediumHash") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PhotoSubjectCollection") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PlanHash") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("SmallHash") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Timestamp") + .HasColumnType("bigint"); + + b.HasKey("PhotoId"); + + b.HasIndex("CreatorId"); + + b.ToTable("Photos"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.PhotoSubject", b => + { + b.Property("PhotoSubjectId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Bounds") + .HasColumnType("longtext"); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("PhotoSubjectId"); + + b.HasIndex("UserId"); + + b.ToTable("PhotoSubjects"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Profiles.Comment", b => + { + b.Property("CommentId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Message") + .HasColumnType("longtext"); + + b.Property("PosterUserId") + .HasColumnType("int"); + + b.Property("TargetUserId") + .HasColumnType("int"); + + b.Property("ThumbsDown") + .HasColumnType("int"); + + b.Property("ThumbsUp") + .HasColumnType("int"); + + b.Property("Timestamp") + .HasColumnType("bigint"); + + b.HasKey("CommentId"); + + b.HasIndex("PosterUserId"); + + b.HasIndex("TargetUserId"); + + b.ToTable("Comments"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Profiles.LastMatch", b => + { + b.Property("UserId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Timestamp") + .HasColumnType("bigint"); + + b.HasKey("UserId"); + + b.ToTable("LastMatches"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Profiles.Location", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("X") + .HasColumnType("int"); + + b.Property("Y") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Locations"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Score", b => + { + b.Property("ScoreId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("PlayerIdCollection") + .HasColumnType("longtext"); + + b.Property("Points") + .HasColumnType("int"); + + b.Property("SlotId") + .HasColumnType("int"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("ScoreId"); + + b.HasIndex("SlotId"); + + b.ToTable("Scores"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.User", b => + { + b.Property("UserId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Biography") + .HasColumnType("longtext"); + + b.Property("Game") + .HasColumnType("int"); + + b.Property("IconHash") + .HasColumnType("longtext"); + + b.Property("LocationId") + .HasColumnType("int"); + + b.Property("Password") + .HasColumnType("longtext"); + + b.Property("Pins") + .HasColumnType("longtext"); + + b.Property("PlanetHash") + .HasColumnType("longtext"); + + b.Property("Username") + .HasColumnType("longtext"); + + b.HasKey("UserId"); + + b.HasIndex("LocationId"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.HeartedProfile", b => + { + b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "HeartedUser") + .WithMany() + .HasForeignKey("HeartedUserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("HeartedUser"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Levels.HeartedLevel", 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.QueuedLevel", 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") + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Creator"); + + b.Navigation("Location"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Levels.VisitedLevel", 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") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Profiles.Comment", b => + { + b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "Poster") + .WithMany() + .HasForeignKey("PosterUserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "Target") + .WithMany() + .HasForeignKey("TargetUserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Poster"); + + b.Navigation("Target"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Score", b => + { + b.HasOne("LBPUnion.ProjectLighthouse.Types.Levels.Slot", "Slot") + .WithMany() + .HasForeignKey("SlotId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + 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"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/ProjectLighthouse/Migrations/20211120052549_RenameTokensToGameTokens.cs b/ProjectLighthouse/Migrations/20211120052549_RenameTokensToGameTokens.cs new file mode 100644 index 00000000..59150955 --- /dev/null +++ b/ProjectLighthouse/Migrations/20211120052549_RenameTokensToGameTokens.cs @@ -0,0 +1,41 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace ProjectLighthouse.Migrations +{ + public partial class RenameTokensToGameTokens : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropPrimaryKey( + name: "PK_Tokens", + table: "Tokens"); + + migrationBuilder.RenameTable( + name: "Tokens", + newName: "GameTokens"); + + migrationBuilder.AddPrimaryKey( + name: "PK_GameTokens", + table: "GameTokens", + column: "TokenId"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropPrimaryKey( + name: "PK_GameTokens", + table: "GameTokens"); + + migrationBuilder.RenameTable( + name: "GameTokens", + newName: "Tokens"); + + migrationBuilder.AddPrimaryKey( + name: "PK_Tokens", + table: "Tokens", + column: "TokenId"); + } + } +} diff --git a/ProjectLighthouse/Migrations/DatabaseModelSnapshot.cs b/ProjectLighthouse/Migrations/DatabaseModelSnapshot.cs index c7ae61ec..c0613f2b 100644 --- a/ProjectLighthouse/Migrations/DatabaseModelSnapshot.cs +++ b/ProjectLighthouse/Migrations/DatabaseModelSnapshot.cs @@ -18,6 +18,29 @@ namespace ProjectLighthouse.Migrations .HasAnnotation("ProductVersion", "6.0.0") .HasAnnotation("Relational:MaxIdentifierLength", 64); + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.GameToken", b => + { + b.Property("TokenId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("GameVersion") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("int"); + + b.Property("UserLocation") + .HasColumnType("longtext"); + + b.Property("UserToken") + .HasColumnType("longtext"); + + b.HasKey("TokenId"); + + b.ToTable("GameTokens"); + }); + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.HeartedProfile", b => { b.Property("HeartedProfileId") @@ -410,29 +433,6 @@ namespace ProjectLighthouse.Migrations b.ToTable("Scores"); }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Token", b => - { - b.Property("TokenId") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("GameVersion") - .HasColumnType("int"); - - b.Property("UserId") - .HasColumnType("int"); - - b.Property("UserLocation") - .HasColumnType("longtext"); - - b.Property("UserToken") - .HasColumnType("longtext"); - - b.HasKey("TokenId"); - - b.ToTable("Tokens"); - }); - modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.User", b => { b.Property("UserId") diff --git a/ProjectLighthouse/Types/Token.cs b/ProjectLighthouse/Types/GameToken.cs similarity index 93% rename from ProjectLighthouse/Types/Token.cs rename to ProjectLighthouse/Types/GameToken.cs index fc448c8c..64b19217 100644 --- a/ProjectLighthouse/Types/Token.cs +++ b/ProjectLighthouse/Types/GameToken.cs @@ -2,7 +2,7 @@ using System.ComponentModel.DataAnnotations; namespace LBPUnion.ProjectLighthouse.Types { - public class Token + public class GameToken { // ReSharper disable once UnusedMember.Global [Key] From 21fd62ac1c70d6da2d0853cba92ceb2c52c87eb6 Mon Sep 17 00:00:00 2001 From: jvyden Date: Sat, 20 Nov 2021 00:59:16 -0500 Subject: [PATCH 009/123] Add WebTokens, send cookie on successful login --- ProjectLighthouse/Database.cs | 1 + .../20211120053654_AddWebTokens.Designer.cs | 671 ++++++++++++++++++ .../Migrations/20211120053654_AddWebTokens.cs | 35 + .../Migrations/DatabaseModelSnapshot.cs | 17 + .../Pages/ExternalAuth/LoginForm.cshtml.cs | 15 +- ProjectLighthouse/Types/WebToken.cs | 15 + 6 files changed, 752 insertions(+), 2 deletions(-) create mode 100644 ProjectLighthouse/Migrations/20211120053654_AddWebTokens.Designer.cs create mode 100644 ProjectLighthouse/Migrations/20211120053654_AddWebTokens.cs create mode 100644 ProjectLighthouse/Types/WebToken.cs diff --git a/ProjectLighthouse/Database.cs b/ProjectLighthouse/Database.cs index e71ca13b..1f291fcd 100644 --- a/ProjectLighthouse/Database.cs +++ b/ProjectLighthouse/Database.cs @@ -23,6 +23,7 @@ namespace LBPUnion.ProjectLighthouse public DbSet HeartedProfiles { get; set; } public DbSet Comments { get; set; } public DbSet GameTokens { get; set; } + public DbSet WebTokens { get; set; } public DbSet Scores { get; set; } public DbSet PhotoSubjects { get; set; } public DbSet Photos { get; set; } diff --git a/ProjectLighthouse/Migrations/20211120053654_AddWebTokens.Designer.cs b/ProjectLighthouse/Migrations/20211120053654_AddWebTokens.Designer.cs new file mode 100644 index 00000000..fe402f9f --- /dev/null +++ b/ProjectLighthouse/Migrations/20211120053654_AddWebTokens.Designer.cs @@ -0,0 +1,671 @@ +// +using LBPUnion.ProjectLighthouse; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace ProjectLighthouse.Migrations +{ + [DbContext(typeof(Database))] + [Migration("20211120053654_AddWebTokens")] + partial class AddWebTokens + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.GameToken", b => + { + b.Property("TokenId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("GameVersion") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("int"); + + b.Property("UserLocation") + .HasColumnType("longtext"); + + b.Property("UserToken") + .HasColumnType("longtext"); + + b.HasKey("TokenId"); + + 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 => + { + b.Property("HeartedLevelId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("SlotId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("HeartedLevelId"); + + b.HasIndex("SlotId"); + + b.HasIndex("UserId"); + + b.ToTable("HeartedLevels"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Levels.QueuedLevel", b => + { + b.Property("QueuedLevelId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("SlotId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("QueuedLevelId"); + + b.HasIndex("SlotId"); + + b.HasIndex("UserId"); + + b.ToTable("QueuedLevels"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Levels.RatedLevel", b => + { + b.Property("RatedLevelId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Rating") + .HasColumnType("int"); + + b.Property("RatingLBP1") + .HasColumnType("double"); + + b.Property("SlotId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("RatedLevelId"); + + b.HasIndex("SlotId"); + + b.HasIndex("UserId"); + + b.ToTable("RatedLevels"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Levels.Slot", b => + { + b.Property("SlotId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("AuthorLabels") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("BackgroundHash") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CreatorId") + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FirstUploaded") + .HasColumnType("bigint"); + + b.Property("GameVersion") + .HasColumnType("int"); + + b.Property("IconHash") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("InitiallyLocked") + .HasColumnType("tinyint(1)"); + + b.Property("LastUpdated") + .HasColumnType("bigint"); + + b.Property("Lbp1Only") + .HasColumnType("tinyint(1)"); + + b.Property("LevelType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("LocationId") + .HasColumnType("int"); + + b.Property("MaximumPlayers") + .HasColumnType("int"); + + b.Property("MinimumPlayers") + .HasColumnType("int"); + + b.Property("MoveRequired") + .HasColumnType("tinyint(1)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PlaysLBP1") + .HasColumnType("int"); + + b.Property("PlaysLBP1Complete") + .HasColumnType("int"); + + b.Property("PlaysLBP1Unique") + .HasColumnType("int"); + + b.Property("PlaysLBP2") + .HasColumnType("int"); + + b.Property("PlaysLBP2Complete") + .HasColumnType("int"); + + b.Property("PlaysLBP2Unique") + .HasColumnType("int"); + + b.Property("PlaysLBP3") + .HasColumnType("int"); + + b.Property("PlaysLBP3Complete") + .HasColumnType("int"); + + b.Property("PlaysLBP3Unique") + .HasColumnType("int"); + + b.Property("PlaysLBPVita") + .HasColumnType("int"); + + b.Property("PlaysLBPVitaComplete") + .HasColumnType("int"); + + b.Property("PlaysLBPVitaUnique") + .HasColumnType("int"); + + b.Property("ResourceCollection") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("RootLevel") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Shareable") + .HasColumnType("int"); + + b.Property("SubLevel") + .HasColumnType("tinyint(1)"); + + b.Property("TeamPick") + .HasColumnType("tinyint(1)"); + + b.HasKey("SlotId"); + + b.HasIndex("CreatorId"); + + b.HasIndex("LocationId"); + + b.ToTable("Slots"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Levels.VisitedLevel", b => + { + b.Property("VisitedLevelId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("PlaysLBP1") + .HasColumnType("int"); + + b.Property("PlaysLBP2") + .HasColumnType("int"); + + b.Property("PlaysLBP3") + .HasColumnType("int"); + + b.Property("PlaysLBPVita") + .HasColumnType("int"); + + b.Property("SlotId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("VisitedLevelId"); + + b.HasIndex("SlotId"); + + b.HasIndex("UserId"); + + b.ToTable("VisitedLevels"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Photo", b => + { + b.Property("PhotoId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("CreatorId") + .HasColumnType("int"); + + b.Property("LargeHash") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MediumHash") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PhotoSubjectCollection") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PlanHash") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("SmallHash") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Timestamp") + .HasColumnType("bigint"); + + b.HasKey("PhotoId"); + + b.HasIndex("CreatorId"); + + b.ToTable("Photos"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.PhotoSubject", b => + { + b.Property("PhotoSubjectId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Bounds") + .HasColumnType("longtext"); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("PhotoSubjectId"); + + b.HasIndex("UserId"); + + b.ToTable("PhotoSubjects"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Profiles.Comment", b => + { + b.Property("CommentId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Message") + .HasColumnType("longtext"); + + b.Property("PosterUserId") + .HasColumnType("int"); + + b.Property("TargetUserId") + .HasColumnType("int"); + + b.Property("ThumbsDown") + .HasColumnType("int"); + + b.Property("ThumbsUp") + .HasColumnType("int"); + + b.Property("Timestamp") + .HasColumnType("bigint"); + + b.HasKey("CommentId"); + + b.HasIndex("PosterUserId"); + + b.HasIndex("TargetUserId"); + + b.ToTable("Comments"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Profiles.LastMatch", b => + { + b.Property("UserId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Timestamp") + .HasColumnType("bigint"); + + b.HasKey("UserId"); + + b.ToTable("LastMatches"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Profiles.Location", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("X") + .HasColumnType("int"); + + b.Property("Y") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Locations"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Score", b => + { + b.Property("ScoreId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("PlayerIdCollection") + .HasColumnType("longtext"); + + b.Property("Points") + .HasColumnType("int"); + + b.Property("SlotId") + .HasColumnType("int"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("ScoreId"); + + b.HasIndex("SlotId"); + + b.ToTable("Scores"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.User", b => + { + b.Property("UserId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Biography") + .HasColumnType("longtext"); + + b.Property("Game") + .HasColumnType("int"); + + b.Property("IconHash") + .HasColumnType("longtext"); + + b.Property("LocationId") + .HasColumnType("int"); + + b.Property("Password") + .HasColumnType("longtext"); + + b.Property("Pins") + .HasColumnType("longtext"); + + b.Property("PlanetHash") + .HasColumnType("longtext"); + + b.Property("Username") + .HasColumnType("longtext"); + + b.HasKey("UserId"); + + b.HasIndex("LocationId"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.WebToken", b => + { + b.Property("TokenId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("int"); + + b.Property("UserToken") + .HasColumnType("longtext"); + + b.HasKey("TokenId"); + + b.ToTable("WebTokens"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.HeartedProfile", b => + { + b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "HeartedUser") + .WithMany() + .HasForeignKey("HeartedUserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("HeartedUser"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Levels.HeartedLevel", 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.QueuedLevel", 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") + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Creator"); + + b.Navigation("Location"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Levels.VisitedLevel", 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") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Profiles.Comment", b => + { + b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "Poster") + .WithMany() + .HasForeignKey("PosterUserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "Target") + .WithMany() + .HasForeignKey("TargetUserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Poster"); + + b.Navigation("Target"); + }); + + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Score", b => + { + b.HasOne("LBPUnion.ProjectLighthouse.Types.Levels.Slot", "Slot") + .WithMany() + .HasForeignKey("SlotId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + 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"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/ProjectLighthouse/Migrations/20211120053654_AddWebTokens.cs b/ProjectLighthouse/Migrations/20211120053654_AddWebTokens.cs new file mode 100644 index 00000000..7fe503b6 --- /dev/null +++ b/ProjectLighthouse/Migrations/20211120053654_AddWebTokens.cs @@ -0,0 +1,35 @@ +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace ProjectLighthouse.Migrations +{ + public partial class AddWebTokens : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "WebTokens", + columns: table => new + { + TokenId = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + UserId = table.Column(type: "int", nullable: false), + UserToken = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_WebTokens", x => x.TokenId); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "WebTokens"); + } + } +} diff --git a/ProjectLighthouse/Migrations/DatabaseModelSnapshot.cs b/ProjectLighthouse/Migrations/DatabaseModelSnapshot.cs index c0613f2b..411f8fe7 100644 --- a/ProjectLighthouse/Migrations/DatabaseModelSnapshot.cs +++ b/ProjectLighthouse/Migrations/DatabaseModelSnapshot.cs @@ -470,6 +470,23 @@ namespace ProjectLighthouse.Migrations b.ToTable("Users"); }); + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.WebToken", b => + { + b.Property("TokenId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("int"); + + b.Property("UserToken") + .HasColumnType("longtext"); + + b.HasKey("TokenId"); + + b.ToTable("WebTokens"); + }); + modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.HeartedProfile", b => { b.HasOne("LBPUnion.ProjectLighthouse.Types.User", "HeartedUser") diff --git a/ProjectLighthouse/Pages/ExternalAuth/LoginForm.cshtml.cs b/ProjectLighthouse/Pages/ExternalAuth/LoginForm.cshtml.cs index c49355ce..92388fa5 100644 --- a/ProjectLighthouse/Pages/ExternalAuth/LoginForm.cshtml.cs +++ b/ProjectLighthouse/Pages/ExternalAuth/LoginForm.cshtml.cs @@ -1,7 +1,7 @@ #nullable enable -using System; using System.Threading.Tasks; using JetBrains.Annotations; +using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Pages.Layouts; using LBPUnion.ProjectLighthouse.Types; using Microsoft.AspNetCore.Mvc; @@ -32,7 +32,18 @@ namespace LBPUnion.ProjectLighthouse.Pages.ExternalAuth if (!BCrypt.Net.BCrypt.Verify(password, user.Password)) return this.StatusCode(403, ""); - Console.WriteLine(user.UserId); + WebToken webToken = new() + { + UserId = user.UserId, + UserToken = HashHelper.GenerateAuthToken(), + }; + + this.database.WebTokens.Add(webToken); + await this.database.SaveChangesAsync(); + + this.Response.Cookies.Append("LighthouseToken", webToken.UserToken); + + return this.RedirectToPage(nameof(LandingPage)); } return this.Page(); diff --git a/ProjectLighthouse/Types/WebToken.cs b/ProjectLighthouse/Types/WebToken.cs new file mode 100644 index 00000000..2bf8fe9c --- /dev/null +++ b/ProjectLighthouse/Types/WebToken.cs @@ -0,0 +1,15 @@ +using System.ComponentModel.DataAnnotations; + +namespace LBPUnion.ProjectLighthouse.Types +{ + public class WebToken + { + // ReSharper disable once UnusedMember.Global + [Key] + public int TokenId { get; set; } + + public int UserId { get; set; } + + public string UserToken { get; set; } + } +} \ No newline at end of file From ff823b5ae6c847b513fa7afd2633a7e7dd1cadc3 Mon Sep 17 00:00:00 2001 From: jvyden Date: Sat, 20 Nov 2021 01:21:31 -0500 Subject: [PATCH 010/123] Rename Game authentication methods as such --- .../Controllers/CommentController.cs | 4 ++-- .../Controllers/EnterLevelController.cs | 6 ++--- .../Controllers/FriendsController.cs | 4 ++-- .../Controllers/ListController.cs | 20 ++++++++--------- .../Controllers/LoginController.cs | 2 +- .../Controllers/MatchController.cs | 2 +- .../Controllers/MessageController.cs | 4 ++-- .../Controllers/PhotosController.cs | 4 ++-- .../Controllers/PublishController.cs | 8 +++---- .../Controllers/ReviewController.cs | 4 ++-- .../Controllers/ScoreController.cs | 4 ++-- .../Controllers/SlotsController.cs | 12 +++++----- .../Controllers/UserController.cs | 8 +++---- ProjectLighthouse/Database.cs | 22 +++++++++++++------ 14 files changed, 56 insertions(+), 48 deletions(-) diff --git a/ProjectLighthouse/Controllers/CommentController.cs b/ProjectLighthouse/Controllers/CommentController.cs index fd7cbbbf..de9ffa5c 100644 --- a/ProjectLighthouse/Controllers/CommentController.cs +++ b/ProjectLighthouse/Controllers/CommentController.cs @@ -47,7 +47,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers XmlSerializer serializer = new(typeof(Comment)); Comment? comment = (Comment?)serializer.Deserialize(new StringReader(bodyString)); - User? poster = await this.database.UserFromRequest(this.Request); + User? poster = await this.database.UserFromGameRequest(this.Request); if (poster == null) return this.StatusCode(403, ""); User? target = await this.database.Users.FirstOrDefaultAsync(u => u.Username == username); @@ -66,7 +66,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers [HttpPost("deleteUserComment/{username}")] public async Task DeleteComment([FromQuery] int commentId, string username) { - User? user = await this.database.UserFromRequest(this.Request); + User? user = await this.database.UserFromGameRequest(this.Request); if (user == null) return this.StatusCode(403, ""); Comment? comment = await this.database.Comments.FirstOrDefaultAsync(c => c.CommentId == commentId); diff --git a/ProjectLighthouse/Controllers/EnterLevelController.cs b/ProjectLighthouse/Controllers/EnterLevelController.cs index de4d4e0a..ba24c642 100644 --- a/ProjectLighthouse/Controllers/EnterLevelController.cs +++ b/ProjectLighthouse/Controllers/EnterLevelController.cs @@ -24,13 +24,13 @@ namespace LBPUnion.ProjectLighthouse.Controllers [HttpPost("play/user/{slotId}")] public async Task PlayLevel(int slotId) { - User? user = await this.database.UserFromRequest(this.Request); + User? user = await this.database.UserFromGameRequest(this.Request); if (user == null) return this.StatusCode(403, ""); Slot? slot = await this.database.Slots.FirstOrDefaultAsync(s => s.SlotId == slotId); if (slot == null) return this.StatusCode(403, ""); - GameToken? token = await this.database.TokenFromRequest(this.Request); + GameToken? token = await this.database.GameTokenFromRequest(this.Request); if (token == null) return this.StatusCode(403, ""); GameVersion gameVersion = token.GameVersion; @@ -97,7 +97,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers [HttpGet("enterLevel/{id:int}")] public async Task EnterLevel(int id) { - User? user = await this.database.UserFromRequest(this.Request); + User? user = await this.database.UserFromGameRequest(this.Request); if (user == null) return this.StatusCode(403, ""); Slot? slot = await this.database.Slots.FirstOrDefaultAsync(s => s.SlotId == id); diff --git a/ProjectLighthouse/Controllers/FriendsController.cs b/ProjectLighthouse/Controllers/FriendsController.cs index 34648a1b..9fc3b414 100644 --- a/ProjectLighthouse/Controllers/FriendsController.cs +++ b/ProjectLighthouse/Controllers/FriendsController.cs @@ -26,7 +26,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers [HttpPost("npdata")] public async Task NPData() { - User? user = await this.database.UserFromRequest(this.Request); + User? user = await this.database.UserFromGameRequest(this.Request); if (user == null) return this.StatusCode(403, ""); this.Request.Body.Position = 0; @@ -69,7 +69,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers [HttpGet("myFriends")] public async Task MyFriends() { - (User, GameToken)? userAndToken = await this.database.UserAndTokenFromRequest(this.Request); + (User, GameToken)? userAndToken = await this.database.UserAndGameTokenFromRequest(this.Request); if (userAndToken == null) return this.StatusCode(403, ""); diff --git a/ProjectLighthouse/Controllers/ListController.cs b/ProjectLighthouse/Controllers/ListController.cs index 8c01c333..7b751551 100644 --- a/ProjectLighthouse/Controllers/ListController.cs +++ b/ProjectLighthouse/Controllers/ListController.cs @@ -29,7 +29,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers [HttpGet("slots/lolcatftw/{username}")] public async Task GetLevelQueue(string username, [FromQuery] int pageSize, [FromQuery] int pageStart) { - GameToken? token = await this.database.TokenFromRequest(this.Request); + GameToken? token = await this.database.GameTokenFromRequest(this.Request); if (token == null) return this.StatusCode(403, ""); GameVersion gameVersion = token.GameVersion; @@ -56,7 +56,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers [HttpPost("lolcatftw/add/user/{id:int}")] public async Task AddQueuedLevel(int id) { - User? user = await this.database.UserFromRequest(this.Request); + User? user = await this.database.UserFromGameRequest(this.Request); if (user == null) return this.StatusCode(403, ""); QueuedLevel? queuedLevel = await this.database.QueuedLevels.FirstOrDefaultAsync(q => q.UserId == user.UserId && q.SlotId == id); @@ -79,7 +79,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers [HttpPost("lolcatftw/remove/user/{id:int}")] public async Task RemoveQueuedLevel(int id) { - User? user = await this.database.UserFromRequest(this.Request); + User? user = await this.database.UserFromGameRequest(this.Request); if (user == null) return this.StatusCode(403, ""); QueuedLevel? queuedLevel = await this.database.QueuedLevels.FirstOrDefaultAsync(q => q.UserId == user.UserId && q.SlotId == id); @@ -93,7 +93,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers [HttpPost("lolcatftw/clear")] public async Task ClearQueuedLevels() { - User? user = await this.database.UserFromRequest(this.Request); + User? user = await this.database.UserFromGameRequest(this.Request); if (user == null) return this.StatusCode(403, ""); this.database.QueuedLevels.RemoveRange(this.database.QueuedLevels.Where(q => q.UserId == user.UserId)); @@ -110,7 +110,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers [HttpGet("favouriteSlots/{username}")] public async Task GetFavouriteSlots(string username, [FromQuery] int pageSize, [FromQuery] int pageStart) { - GameToken? token = await this.database.TokenFromRequest(this.Request); + GameToken? token = await this.database.GameTokenFromRequest(this.Request); if (token == null) return this.StatusCode(403, ""); GameVersion gameVersion = token.GameVersion; @@ -137,7 +137,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers [HttpPost("favourite/slot/user/{id:int}")] public async Task AddFavouriteSlot(int id) { - User? user = await this.database.UserFromRequest(this.Request); + User? user = await this.database.UserFromGameRequest(this.Request); if (user == null) return this.StatusCode(403, ""); HeartedLevel? heartedLevel = await this.database.HeartedLevels.FirstOrDefaultAsync(q => q.UserId == user.UserId && q.SlotId == id); @@ -160,7 +160,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers [HttpPost("unfavourite/slot/user/{id:int}")] public async Task RemoveFavouriteSlot(int id) { - User? user = await this.database.UserFromRequest(this.Request); + User? user = await this.database.UserFromGameRequest(this.Request); if (user == null) return this.StatusCode(403, ""); HeartedLevel? heartedLevel = await this.database.HeartedLevels.FirstOrDefaultAsync(q => q.UserId == user.UserId && q.SlotId == id); @@ -180,7 +180,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers [HttpGet("favouriteUsers/{username}")] public async Task GetFavouriteUsers(string username, [FromQuery] int pageSize, [FromQuery] int pageStart) { - GameToken? token = await this.database.TokenFromRequest(this.Request); + GameToken? token = await this.database.GameTokenFromRequest(this.Request); if (token == null) return this.StatusCode(403, ""); IEnumerable heartedProfiles = this.database.HeartedProfiles.Include @@ -204,7 +204,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers [HttpPost("favourite/user/{username}")] public async Task AddFavouriteUser(string username) { - User? user = await this.database.UserFromRequest(this.Request); + User? user = await this.database.UserFromGameRequest(this.Request); if (user == null) return this.StatusCode(403, ""); User? heartedUser = await this.database.Users.FirstOrDefaultAsync(u => u.Username == username); @@ -231,7 +231,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers [HttpPost("unfavourite/user/{username}")] public async Task RemoveFavouriteUser(string username) { - User? user = await this.database.UserFromRequest(this.Request); + User? user = await this.database.UserFromGameRequest(this.Request); if (user == null) return this.StatusCode(403, ""); User? heartedUser = await this.database.Users.FirstOrDefaultAsync(u => u.Username == username); diff --git a/ProjectLighthouse/Controllers/LoginController.cs b/ProjectLighthouse/Controllers/LoginController.cs index a3384241..2a1a9999 100644 --- a/ProjectLighthouse/Controllers/LoginController.cs +++ b/ProjectLighthouse/Controllers/LoginController.cs @@ -49,7 +49,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers GameToken? token = await this.database.AuthenticateUser(loginData, userLocation, titleId); if (token == null) return this.StatusCode(403, ""); - User? user = await this.database.UserFromToken(token); + User? user = await this.database.UserFromGameToken(token); if (user == null) return this.StatusCode(403, ""); Logger.Log($"Successfully logged in user {user.Username} as {token.GameVersion} client ({titleId})", LoggerLevelLogin.Instance); diff --git a/ProjectLighthouse/Controllers/MatchController.cs b/ProjectLighthouse/Controllers/MatchController.cs index ea448bba..87bd6e31 100644 --- a/ProjectLighthouse/Controllers/MatchController.cs +++ b/ProjectLighthouse/Controllers/MatchController.cs @@ -32,7 +32,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers [Produces("text/plain")] public async Task Match() { - (User, GameToken)? userAndToken = await this.database.UserAndTokenFromRequest(this.Request); + (User, GameToken)? userAndToken = await this.database.UserAndGameTokenFromRequest(this.Request); if (userAndToken == null) return this.StatusCode(403, ""); diff --git a/ProjectLighthouse/Controllers/MessageController.cs b/ProjectLighthouse/Controllers/MessageController.cs index beab0d93..1e31bc29 100644 --- a/ProjectLighthouse/Controllers/MessageController.cs +++ b/ProjectLighthouse/Controllers/MessageController.cs @@ -27,7 +27,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers [HttpGet("announce")] public async Task Announce() { - User user = await this.database.UserFromRequest(this.Request); + User user = await this.database.UserFromGameRequest(this.Request); if (user == null) return this.StatusCode(403, ""); return this.Ok($"You are now logged in as user {user.Username} (id {user.UserId}).\n\n" + ServerSettings.Instance.EulaText); @@ -42,7 +42,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers [HttpPost("filter")] public async Task Filter() { - User user = await this.database.UserFromRequest(this.Request); + User user = await this.database.UserFromGameRequest(this.Request); if (user == null) return this.StatusCode(403, ""); string loggedText = await new StreamReader(this.Request.Body).ReadToEndAsync(); diff --git a/ProjectLighthouse/Controllers/PhotosController.cs b/ProjectLighthouse/Controllers/PhotosController.cs index 6dce4228..6d30d184 100644 --- a/ProjectLighthouse/Controllers/PhotosController.cs +++ b/ProjectLighthouse/Controllers/PhotosController.cs @@ -29,7 +29,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers [HttpPost("uploadPhoto")] public async Task UploadPhoto() { - User? user = await this.database.UserFromRequest(this.Request); + User? user = await this.database.UserFromGameRequest(this.Request); if (user == null) return this.StatusCode(403, ""); this.Request.Body.Position = 0; @@ -120,7 +120,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers [HttpPost("deletePhoto/{id:int}")] public async Task DeletePhoto(int id) { - User? user = await this.database.UserFromRequest(this.Request); + User? user = await this.database.UserFromGameRequest(this.Request); if (user == null) return this.StatusCode(403, ""); Photo? photo = await this.database.Photos.FirstOrDefaultAsync(p => p.PhotoId == id); diff --git a/ProjectLighthouse/Controllers/PublishController.cs b/ProjectLighthouse/Controllers/PublishController.cs index 7ce1365c..61444bc0 100644 --- a/ProjectLighthouse/Controllers/PublishController.cs +++ b/ProjectLighthouse/Controllers/PublishController.cs @@ -32,7 +32,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers [HttpPost("startPublish")] public async Task StartPublish() { - User? user = await this.database.UserFromRequest(this.Request); + User? user = await this.database.UserFromGameRequest(this.Request); if (user == null) return this.StatusCode(403, ""); Slot? slot = await this.GetSlotFromBody(); @@ -65,8 +65,8 @@ namespace LBPUnion.ProjectLighthouse.Controllers [HttpPost("publish")] public async Task Publish() { -// User user = await this.database.UserFromRequest(this.Request); - (User, GameToken)? userAndToken = await this.database.UserAndTokenFromRequest(this.Request); +// User user = await this.database.UserFromGameRequest(this.Request); + (User, GameToken)? userAndToken = await this.database.UserAndGameTokenFromRequest(this.Request); if (userAndToken == null) return this.StatusCode(403, ""); @@ -131,7 +131,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers [HttpPost("unpublish/{id:int}")] public async Task Unpublish(int id) { - User? user = await this.database.UserFromRequest(this.Request); + User? user = await this.database.UserFromGameRequest(this.Request); if (user == null) return this.StatusCode(403, ""); Slot? slot = await this.database.Slots.Include(s => s.Location).FirstOrDefaultAsync(s => s.SlotId == id); diff --git a/ProjectLighthouse/Controllers/ReviewController.cs b/ProjectLighthouse/Controllers/ReviewController.cs index c50435af..fa501d3f 100644 --- a/ProjectLighthouse/Controllers/ReviewController.cs +++ b/ProjectLighthouse/Controllers/ReviewController.cs @@ -24,7 +24,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers [HttpPost("rate/user/{slotId}")] public async Task Rate(int slotId, [FromQuery] int rating) { - User? user = await this.database.UserFromRequest(this.Request); + User? user = await this.database.UserFromGameRequest(this.Request); if (user == null) return this.StatusCode(403, ""); Slot? slot = await this.database.Slots.Include(s => s.Creator).Include(s => s.Location).FirstOrDefaultAsync(s => s.SlotId == slotId); @@ -51,7 +51,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers [HttpPost("dpadrate/user/{slotId:int}")] public async Task DPadRate(int slotId, [FromQuery] int rating) { - User? user = await this.database.UserFromRequest(this.Request); + User? user = await this.database.UserFromGameRequest(this.Request); if (user == null) return this.StatusCode(403, ""); Slot? slot = await this.database.Slots.Include(s => s.Creator).Include(s => s.Location).FirstOrDefaultAsync(s => s.SlotId == slotId); diff --git a/ProjectLighthouse/Controllers/ScoreController.cs b/ProjectLighthouse/Controllers/ScoreController.cs index dc0762a8..d97f07e9 100644 --- a/ProjectLighthouse/Controllers/ScoreController.cs +++ b/ProjectLighthouse/Controllers/ScoreController.cs @@ -28,7 +28,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers [HttpPost("scoreboard/user/{id:int}")] public async Task SubmitScore(int id, [FromQuery] bool lbp1 = false, [FromQuery] bool lbp2 = false, [FromQuery] bool lbp3 = false) { - (User, GameToken)? userAndToken = await this.database.UserAndTokenFromRequest(this.Request); + (User, GameToken)? userAndToken = await this.database.UserAndGameTokenFromRequest(this.Request); if (userAndToken == null) return this.StatusCode(403, ""); @@ -95,7 +95,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers public async Task TopScores(int slotId, int type, [FromQuery] int pageStart = -1, [FromQuery] int pageSize = 5) { // Get username - User? user = await this.database.UserFromRequest(this.Request); + User? user = await this.database.UserFromGameRequest(this.Request); if (user == null) return this.StatusCode(403, ""); diff --git a/ProjectLighthouse/Controllers/SlotsController.cs b/ProjectLighthouse/Controllers/SlotsController.cs index c0ee8d96..f305c14e 100644 --- a/ProjectLighthouse/Controllers/SlotsController.cs +++ b/ProjectLighthouse/Controllers/SlotsController.cs @@ -26,7 +26,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers [HttpGet("slots/by")] public async Task SlotsBy([FromQuery] string u, [FromQuery] int pageStart, [FromQuery] int pageSize) { - GameToken? token = await this.database.TokenFromRequest(this.Request); + GameToken? token = await this.database.GameTokenFromRequest(this.Request); if (token == null) return this.StatusCode(403, ""); GameVersion gameVersion = token.GameVersion; @@ -68,10 +68,10 @@ namespace LBPUnion.ProjectLighthouse.Controllers [HttpGet("s/user/{id:int}")] public async Task SUser(int id) { - User? user = await this.database.UserFromRequest(this.Request); + User? user = await this.database.UserFromGameRequest(this.Request); if (user == null) return this.StatusCode(403, ""); - GameToken? token = await this.database.TokenFromRequest(this.Request); + GameToken? token = await this.database.GameTokenFromRequest(this.Request); if (token == null) return this.StatusCode(403, ""); GameVersion gameVersion = token.GameVersion; @@ -95,7 +95,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers [HttpGet("slots")] public async Task NewestSlots([FromQuery] int pageStart, [FromQuery] int pageSize) { - GameToken? token = await this.database.TokenFromRequest(this.Request); + GameToken? token = await this.database.GameTokenFromRequest(this.Request); if (token == null) return this.StatusCode(403, ""); GameVersion gameVersion = token.GameVersion; @@ -114,7 +114,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers [HttpGet("slots/mmpicks")] public async Task TeamPickedSlots([FromQuery] int pageStart, [FromQuery] int pageSize) { - GameToken? token = await this.database.TokenFromRequest(this.Request); + GameToken? token = await this.database.GameTokenFromRequest(this.Request); if (token == null) return this.StatusCode(403, ""); GameVersion gameVersion = token.GameVersion; @@ -134,7 +134,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers [HttpGet("slots/lbp2luckydip")] public async Task LuckyDipSlots([FromQuery] int pageStart, [FromQuery] int pageSize, [FromQuery] int seed) { - GameToken? token = await this.database.TokenFromRequest(this.Request); + GameToken? token = await this.database.GameTokenFromRequest(this.Request); if (token == null) return this.StatusCode(403, ""); GameVersion gameVersion = token.GameVersion; diff --git a/ProjectLighthouse/Controllers/UserController.cs b/ProjectLighthouse/Controllers/UserController.cs index e5badad5..81755bb1 100644 --- a/ProjectLighthouse/Controllers/UserController.cs +++ b/ProjectLighthouse/Controllers/UserController.cs @@ -35,7 +35,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers [HttpGet("user/{username}")] public async Task GetUser(string username) { - GameToken? token = await this.database.TokenFromRequest(this.Request); + GameToken? token = await this.database.GameTokenFromRequest(this.Request); if (token == null) return this.StatusCode(403, ""); string? user = await this.GetSerializedUser(username, token.GameVersion); @@ -47,7 +47,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers [HttpGet("users")] public async Task GetUserAlt([FromQuery] string[] u) { - GameToken? token = await this.database.TokenFromRequest(this.Request); + GameToken? token = await this.database.GameTokenFromRequest(this.Request); if (token == null) return this.StatusCode(403, ""); List serializedUsers = new(); @@ -67,7 +67,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers [HttpPost("updateUser")] public async Task UpdateUser() { - User? user = await this.database.UserFromRequest(this.Request); + User? user = await this.database.UserFromGameRequest(this.Request); if (user == null) return this.StatusCode(403, ""); XmlReaderSettings settings = new() @@ -163,7 +163,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers [HttpPost("update_my_pins")] public async Task UpdateMyPins() { - User? user = await this.database.UserFromRequest(this.Request); + User? user = await this.database.UserFromGameRequest(this.Request); if (user == null) return this.StatusCode(403, ""); string pinsString = await new StreamReader(this.Request.Body).ReadToEndAsync(); diff --git a/ProjectLighthouse/Database.cs b/ProjectLighthouse/Database.cs index 1f291fcd..58f4a190 100644 --- a/ProjectLighthouse/Database.cs +++ b/ProjectLighthouse/Database.cs @@ -86,7 +86,9 @@ namespace LBPUnion.ProjectLighthouse return gameToken; } - public async Task UserFromAuthToken(string authToken) + #region Game Token Shenanigans + + public async Task UserFromMMAuth(string authToken) { GameToken? token = await this.GameTokens.FirstOrDefaultAsync(t => t.UserToken == authToken); if (token == null) return null; @@ -94,36 +96,42 @@ namespace LBPUnion.ProjectLighthouse return await this.Users.Include(u => u.Location).FirstOrDefaultAsync(u => u.UserId == token.UserId); } - public async Task UserFromToken(GameToken gameToken) => await this.UserFromAuthToken(gameToken.UserToken); + public async Task UserFromGameToken(GameToken gameToken) => await this.UserFromMMAuth(gameToken.UserToken); - public async Task UserFromRequest(HttpRequest request) + public async Task UserFromGameRequest(HttpRequest request) { if (!request.Cookies.TryGetValue("MM_AUTH", out string? mmAuth) || mmAuth == null) return null; - return await this.UserFromAuthToken(mmAuth); + return await this.UserFromMMAuth(mmAuth); } - public async Task TokenFromRequest(HttpRequest request) + public async Task GameTokenFromRequest(HttpRequest request) { if (!request.Cookies.TryGetValue("MM_AUTH", out string? mmAuth) || mmAuth == null) return null; return await this.GameTokens.FirstOrDefaultAsync(t => t.UserToken == mmAuth); } - public async Task<(User, GameToken)?> UserAndTokenFromRequest(HttpRequest request) + public async Task<(User, GameToken)?> UserAndGameTokenFromRequest(HttpRequest request) { if (!request.Cookies.TryGetValue("MM_AUTH", out string? mmAuth) || mmAuth == null) return null; GameToken? token = await this.GameTokens.FirstOrDefaultAsync(t => t.UserToken == mmAuth); if (token == null) return null; - User? user = await this.UserFromToken(token); + User? user = await this.UserFromGameToken(token); if (user == null) return null; return (user, token); } + #endregion + + #region Web Token Shenanigans + + #endregion + public async Task PhotoFromSubject(PhotoSubject subject) => await this.Photos.FirstOrDefaultAsync(p => p.PhotoSubjectIds.Contains(subject.PhotoSubjectId.ToString())); #nullable disable From ef76332fdb9702797d468d925456eb38c2bab210 Mon Sep 17 00:00:00 2001 From: jvyden Date: Sat, 20 Nov 2021 01:50:18 -0500 Subject: [PATCH 011/123] Add logout page --- ProjectLighthouse/Database.cs | 22 ++++++++++++++++ .../Pages/ExternalAuth/LandingPage.cshtml | 7 ++++- .../Pages/ExternalAuth/LandingPage.cshtml.cs | 15 ++++++++++- .../Pages/ExternalAuth/LoginForm.cshtml.cs | 14 ++++------ .../Pages/ExternalAuth/LogoutPage.cshtml | 9 +++++++ .../Pages/ExternalAuth/LogoutPage.cshtml.cs | 26 +++++++++++++++++++ .../Pages/ExternalAuth/RegisterForm.cshtml.cs | 12 +++------ .../Pages/Layouts/BaseLayout.cshtml | 14 ++++++++++ .../Pages/Layouts/BaseLayout.cshtml.cs | 13 ++++++++-- 9 files changed, 111 insertions(+), 21 deletions(-) create mode 100644 ProjectLighthouse/Pages/ExternalAuth/LogoutPage.cshtml create mode 100644 ProjectLighthouse/Pages/ExternalAuth/LogoutPage.cshtml.cs diff --git a/ProjectLighthouse/Database.cs b/ProjectLighthouse/Database.cs index 58f4a190..5f9df956 100644 --- a/ProjectLighthouse/Database.cs +++ b/ProjectLighthouse/Database.cs @@ -130,6 +130,28 @@ namespace LBPUnion.ProjectLighthouse #region Web Token Shenanigans + public async Task UserFromLighthouseToken(string lighthouseToken) + { + WebToken? token = await this.WebTokens.FirstOrDefaultAsync(t => t.UserToken == lighthouseToken); + if (token == null) return null; + + return await this.Users.Include(u => u.Location).FirstOrDefaultAsync(u => u.UserId == token.UserId); + } + + public async Task UserFromWebRequest(HttpRequest request) + { + if (!request.Cookies.TryGetValue("LighthouseToken", out string? lighthouseToken) || lighthouseToken == null) return null; + + return await this.UserFromLighthouseToken(lighthouseToken); + } + + public async Task WebTokenFromRequest(HttpRequest request) + { + if (!request.Cookies.TryGetValue("LighthouseToken", out string? lighthouseToken) || lighthouseToken == null) return null; + + return await this.WebTokens.FirstOrDefaultAsync(t => t.UserToken == lighthouseToken); + } + #endregion public async Task PhotoFromSubject(PhotoSubject subject) diff --git a/ProjectLighthouse/Pages/ExternalAuth/LandingPage.cshtml b/ProjectLighthouse/Pages/ExternalAuth/LandingPage.cshtml index 72a62f47..81716c29 100644 --- a/ProjectLighthouse/Pages/ExternalAuth/LandingPage.cshtml +++ b/ProjectLighthouse/Pages/ExternalAuth/LandingPage.cshtml @@ -4,4 +4,9 @@ @{ Layout = "Layouts/BaseLayout"; } -

Welcome to Project Lighthouse.

\ No newline at end of file +

Welcome to Project Lighthouse!

+ +@if (Model.User != null) +{ +

You are currently logged in as @Model.User.Username.

+} \ No newline at end of file diff --git a/ProjectLighthouse/Pages/ExternalAuth/LandingPage.cshtml.cs b/ProjectLighthouse/Pages/ExternalAuth/LandingPage.cshtml.cs index 1afeec59..898e97c4 100644 --- a/ProjectLighthouse/Pages/ExternalAuth/LandingPage.cshtml.cs +++ b/ProjectLighthouse/Pages/ExternalAuth/LandingPage.cshtml.cs @@ -1,12 +1,25 @@ +#nullable enable +using System.Threading.Tasks; using JetBrains.Annotations; using LBPUnion.ProjectLighthouse.Pages.Layouts; +using LBPUnion.ProjectLighthouse.Types; using Microsoft.AspNetCore.Mvc; namespace LBPUnion.ProjectLighthouse.Pages.ExternalAuth { public class LandingPage : BaseLayout { + public LandingPage(Database database) : base(database) + {} + + public new User? User { get; set; } + [UsedImplicitly] - public IActionResult OnGet() => this.Page(); + public async Task OnGet() + { + User = await this.Database.UserFromWebRequest(this.Request); + + return this.Page(); + } } } \ No newline at end of file diff --git a/ProjectLighthouse/Pages/ExternalAuth/LoginForm.cshtml.cs b/ProjectLighthouse/Pages/ExternalAuth/LoginForm.cshtml.cs index 92388fa5..7ba7d451 100644 --- a/ProjectLighthouse/Pages/ExternalAuth/LoginForm.cshtml.cs +++ b/ProjectLighthouse/Pages/ExternalAuth/LoginForm.cshtml.cs @@ -11,12 +11,8 @@ namespace LBPUnion.ProjectLighthouse.Pages.ExternalAuth { public class LoginForm : BaseLayout { - private readonly Database database; - - public LoginForm(Database database) - { - this.database = database; - } + public LoginForm(Database database) : base(database) + {} public bool WasLoginRequest { get; private set; } @@ -27,7 +23,7 @@ namespace LBPUnion.ProjectLighthouse.Pages.ExternalAuth if (WasLoginRequest) { - User? user = await this.database.Users.FirstOrDefaultAsync(u => u.Username == username); + User? user = await this.Database.Users.FirstOrDefaultAsync(u => u.Username == username); if (user == null) return this.StatusCode(403, ""); if (!BCrypt.Net.BCrypt.Verify(password, user.Password)) return this.StatusCode(403, ""); @@ -38,8 +34,8 @@ namespace LBPUnion.ProjectLighthouse.Pages.ExternalAuth UserToken = HashHelper.GenerateAuthToken(), }; - this.database.WebTokens.Add(webToken); - await this.database.SaveChangesAsync(); + this.Database.WebTokens.Add(webToken); + await this.Database.SaveChangesAsync(); this.Response.Cookies.Append("LighthouseToken", webToken.UserToken); diff --git a/ProjectLighthouse/Pages/ExternalAuth/LogoutPage.cshtml b/ProjectLighthouse/Pages/ExternalAuth/LogoutPage.cshtml new file mode 100644 index 00000000..d17124cb --- /dev/null +++ b/ProjectLighthouse/Pages/ExternalAuth/LogoutPage.cshtml @@ -0,0 +1,9 @@ +@page "/logout" +@model LBPUnion.ProjectLighthouse.Pages.ExternalAuth.LogoutPage + +@{ + Layout = "Layouts/BaseLayout"; +} + +

You have been successfully logged out. You will be redirected in 5 seconds, or you may click here to do so manually.

+ \ No newline at end of file diff --git a/ProjectLighthouse/Pages/ExternalAuth/LogoutPage.cshtml.cs b/ProjectLighthouse/Pages/ExternalAuth/LogoutPage.cshtml.cs new file mode 100644 index 00000000..7542466c --- /dev/null +++ b/ProjectLighthouse/Pages/ExternalAuth/LogoutPage.cshtml.cs @@ -0,0 +1,26 @@ +#nullable enable +using System.Threading.Tasks; +using LBPUnion.ProjectLighthouse.Pages.Layouts; +using LBPUnion.ProjectLighthouse.Types; +using Microsoft.AspNetCore.Mvc; + +namespace LBPUnion.ProjectLighthouse.Pages.ExternalAuth +{ + public class LogoutPage : BaseLayout + { + public LogoutPage(Database database) : base(database) + {} + public async Task OnGet() + { + WebToken? token = await this.Database.WebTokenFromRequest(this.Request); + if (token == null) return this.BadRequest(); + + this.Database.WebTokens.Remove(token); + await this.Database.SaveChangesAsync(); + + this.Response.Cookies.Delete("LighthouseToken"); + + return this.Page(); + } + } +} \ No newline at end of file diff --git a/ProjectLighthouse/Pages/ExternalAuth/RegisterForm.cshtml.cs b/ProjectLighthouse/Pages/ExternalAuth/RegisterForm.cshtml.cs index 198dfeb2..6635c552 100644 --- a/ProjectLighthouse/Pages/ExternalAuth/RegisterForm.cshtml.cs +++ b/ProjectLighthouse/Pages/ExternalAuth/RegisterForm.cshtml.cs @@ -11,12 +11,8 @@ namespace LBPUnion.ProjectLighthouse.Pages.ExternalAuth { public class RegisterForm : BaseLayout { - private readonly Database database; - - public RegisterForm(Database database) - { - this.database = database; - } + public RegisterForm(Database database) : base(database) + {} public bool WasRegisterRequest { get; private set; } @@ -32,10 +28,10 @@ namespace LBPUnion.ProjectLighthouse.Pages.ExternalAuth if (WasRegisterRequest) { Console.WriteLine(password); - bool userExists = await this.database.Users.FirstOrDefaultAsync(u => u.Username.ToLower() == username.ToLower()) != null; + bool userExists = await this.Database.Users.FirstOrDefaultAsync(u => u.Username.ToLower() == username.ToLower()) != null; if (userExists) return this.BadRequest(); - this.database.CreateUser(username, HashHelper.BCryptHash(password)); + this.Database.CreateUser(username, HashHelper.BCryptHash(password)); } return this.Page(); diff --git a/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml b/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml index 183b3fe7..bc352fba 100644 --- a/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml +++ b/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml @@ -2,6 +2,20 @@ @using LBPUnion.ProjectLighthouse.Types @model LBPUnion.ProjectLighthouse.Pages.Layouts.BaseLayout +@{ + Model!.User = await Model.Database.UserFromWebRequest(Model.Request); + + if (Model.User == null) + { + Model.NavigationItems.Add(new PageNavigationItem("Register", "/register")); + Model.NavigationItems.Add(new PageNavigationItem("Log in", "/login")); + } + else + { + Model.NavigationItems.Add(new PageNavigationItem("Log out", "/logout")); + } +} + diff --git a/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml.cs b/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml.cs index cfcd8349..e0ddf9c4 100644 --- a/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml.cs +++ b/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml.cs @@ -1,3 +1,4 @@ +#nullable enable using System.Collections.Generic; using LBPUnion.ProjectLighthouse.Types; using Microsoft.AspNetCore.Mvc.RazorPages; @@ -6,11 +7,19 @@ namespace LBPUnion.ProjectLighthouse.Pages.Layouts { public class BaseLayout : PageModel { + public readonly Database Database; + + public new User? User { get; set; } + + public BaseLayout(Database database) + { + this.Database = database; + } + public readonly List NavigationItems = new() { new PageNavigationItem("Home", "/"), - new PageNavigationItem("Register", "/register"), - new PageNavigationItem("Login", "/login"), }; + } } \ No newline at end of file From 8d01130ce20577afa45e65298e04a2ea05f31463 Mon Sep 17 00:00:00 2001 From: jvyden Date: Sat, 20 Nov 2021 02:01:48 -0500 Subject: [PATCH 012/123] update datasources --- .idea/.idea.ProjectLighthouse/.idea/dataSources.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.idea/.idea.ProjectLighthouse/.idea/dataSources.xml b/.idea/.idea.ProjectLighthouse/.idea/dataSources.xml index 4b88ef02..c64bade5 100644 --- a/.idea/.idea.ProjectLighthouse/.idea/dataSources.xml +++ b/.idea/.idea.ProjectLighthouse/.idea/dataSources.xml @@ -8,5 +8,12 @@ jdbc:mysql://localhost:3306/lighthouse $ProjectFileDir$ + + mariadb + true + org.mariadb.jdbc.Driver + jdbc:mariadb://localhost:3306 + $ProjectFileDir$ + \ No newline at end of file From f005aca48c977d557127dc280ea9b084e9113b39 Mon Sep 17 00:00:00 2001 From: jvyden Date: Sat, 20 Nov 2021 02:21:42 -0500 Subject: [PATCH 013/123] sha256 passwords client-side before sending (why didn't I do this before?) --- .../.idea/jsLibraryMappings.xml | 6 ++++++ .../Pages/ExternalAuth/LoginForm.cshtml | 15 ++++++++++++++- .../Pages/ExternalAuth/RegisterForm.cshtml | 17 ++++++++++++++++- .../Pages/ExternalAuth/RegisterForm.cshtml.cs | 11 ++++------- 4 files changed, 40 insertions(+), 9 deletions(-) create mode 100644 .idea/.idea.ProjectLighthouse/.idea/jsLibraryMappings.xml diff --git a/.idea/.idea.ProjectLighthouse/.idea/jsLibraryMappings.xml b/.idea/.idea.ProjectLighthouse/.idea/jsLibraryMappings.xml new file mode 100644 index 00000000..923bf2ee --- /dev/null +++ b/.idea/.idea.ProjectLighthouse/.idea/jsLibraryMappings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ProjectLighthouse/Pages/ExternalAuth/LoginForm.cshtml b/ProjectLighthouse/Pages/ExternalAuth/LoginForm.cshtml index 8f066355..4dd2fefd 100644 --- a/ProjectLighthouse/Pages/ExternalAuth/LoginForm.cshtml +++ b/ProjectLighthouse/Pages/ExternalAuth/LoginForm.cshtml @@ -4,8 +4,21 @@ @{ Layout = "Layouts/BaseLayout"; } + + + + +

Log in

-
+
diff --git a/ProjectLighthouse/Pages/ExternalAuth/RegisterForm.cshtml b/ProjectLighthouse/Pages/ExternalAuth/RegisterForm.cshtml index e3c012d7..89dee5c4 100644 --- a/ProjectLighthouse/Pages/ExternalAuth/RegisterForm.cshtml +++ b/ProjectLighthouse/Pages/ExternalAuth/RegisterForm.cshtml @@ -5,8 +5,23 @@ Layout = "Layouts/BaseLayout"; } + + + + +

Register

- +
diff --git a/ProjectLighthouse/Pages/ExternalAuth/RegisterForm.cshtml.cs b/ProjectLighthouse/Pages/ExternalAuth/RegisterForm.cshtml.cs index 6635c552..de254889 100644 --- a/ProjectLighthouse/Pages/ExternalAuth/RegisterForm.cshtml.cs +++ b/ProjectLighthouse/Pages/ExternalAuth/RegisterForm.cshtml.cs @@ -1,4 +1,3 @@ -using System; using System.Diagnostics.CodeAnalysis; using System.Threading.Tasks; using JetBrains.Annotations; @@ -20,18 +19,16 @@ namespace LBPUnion.ProjectLighthouse.Pages.ExternalAuth [SuppressMessage("ReSharper", "SpecifyStringComparison")] public async Task OnGet([FromQuery] string username, [FromQuery] string password, [FromQuery] string confirmPassword) { - this.WasRegisterRequest = !string.IsNullOrEmpty(username) && - !string.IsNullOrEmpty(password) && - !string.IsNullOrEmpty(confirmPassword) && - password == confirmPassword; + this.WasRegisterRequest = !string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password) && !string.IsNullOrEmpty(confirmPassword); if (WasRegisterRequest) { - Console.WriteLine(password); + if (password != confirmPassword) return this.BadRequest(); + bool userExists = await this.Database.Users.FirstOrDefaultAsync(u => u.Username.ToLower() == username.ToLower()) != null; if (userExists) return this.BadRequest(); - this.Database.CreateUser(username, HashHelper.BCryptHash(password)); + await this.Database.CreateUser(username, HashHelper.BCryptHash(password)); } return this.Page(); From bb742cfbbcae2aa1c130fc0a8db68eb0a228b7fd Mon Sep 17 00:00:00 2001 From: jvyden Date: Sat, 20 Nov 2021 02:35:50 -0500 Subject: [PATCH 014/123] Log in user after registering --- .../Pages/ExternalAuth/RegisterForm.cshtml.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/ProjectLighthouse/Pages/ExternalAuth/RegisterForm.cshtml.cs b/ProjectLighthouse/Pages/ExternalAuth/RegisterForm.cshtml.cs index de254889..6fb36a90 100644 --- a/ProjectLighthouse/Pages/ExternalAuth/RegisterForm.cshtml.cs +++ b/ProjectLighthouse/Pages/ExternalAuth/RegisterForm.cshtml.cs @@ -3,6 +3,7 @@ using System.Threading.Tasks; using JetBrains.Annotations; using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Pages.Layouts; +using LBPUnion.ProjectLighthouse.Types; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; @@ -28,7 +29,20 @@ namespace LBPUnion.ProjectLighthouse.Pages.ExternalAuth bool userExists = await this.Database.Users.FirstOrDefaultAsync(u => u.Username.ToLower() == username.ToLower()) != null; if (userExists) return this.BadRequest(); - await this.Database.CreateUser(username, HashHelper.BCryptHash(password)); + User user = await this.Database.CreateUser(username, HashHelper.BCryptHash(password)); + + WebToken webToken = new() + { + UserId = user.UserId, + UserToken = HashHelper.GenerateAuthToken(), + }; + + this.Database.WebTokens.Add(webToken); + await this.Database.SaveChangesAsync(); + + this.Response.Cookies.Append("LighthouseToken", webToken.UserToken); + + return this.RedirectToPage(nameof(LandingPage)); } return this.Page(); From bf759713bdd0862d583c199edcb30eb909a89b11 Mon Sep 17 00:00:00 2001 From: jvyden Date: Sat, 20 Nov 2021 02:54:22 -0500 Subject: [PATCH 015/123] Add authentication page --- ProjectLighthouse.sln.DotSettings | 2 ++ .../ExternalAuth/AuthenticationPage.cshtml | 18 +++++++++++ .../ExternalAuth/AuthenticationPage.cshtml.cs | 30 +++++++++++++++++++ .../Pages/Layouts/BaseLayout.cshtml | 3 +- .../Types/AuthenticationAttempt.cs | 10 +++++++ ProjectLighthouse/Types/Platform.cs | 8 +++++ 6 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 ProjectLighthouse/Pages/ExternalAuth/AuthenticationPage.cshtml create mode 100644 ProjectLighthouse/Pages/ExternalAuth/AuthenticationPage.cshtml.cs create mode 100644 ProjectLighthouse/Types/AuthenticationAttempt.cs create mode 100644 ProjectLighthouse/Types/Platform.cs diff --git a/ProjectLighthouse.sln.DotSettings b/ProjectLighthouse.sln.DotSettings index 34c3a59a..54a00f4c 100644 --- a/ProjectLighthouse.sln.DotSettings +++ b/ProjectLighthouse.sln.DotSettings @@ -78,7 +78,9 @@ MM NAT NP + PS PSP + RPCS <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb"><ExtraRule Prefix="" Suffix="" Style="aaBb" /></Policy> <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> diff --git a/ProjectLighthouse/Pages/ExternalAuth/AuthenticationPage.cshtml b/ProjectLighthouse/Pages/ExternalAuth/AuthenticationPage.cshtml new file mode 100644 index 00000000..f53deacf --- /dev/null +++ b/ProjectLighthouse/Pages/ExternalAuth/AuthenticationPage.cshtml @@ -0,0 +1,18 @@ +@page "/authentication" +@using LBPUnion.ProjectLighthouse.Types +@model LBPUnion.ProjectLighthouse.Pages.ExternalAuth.AuthenticationPage + +@{ + Layout = "Layouts/BaseLayout"; +} +
+@foreach (AuthenticationAttempt authAttempt in Model.AuthenticationAttempts) +{ +
+

A @authAttempt.Platform authentication request was logged at @authAttempt.Timestamp from the IP address @authAttempt.IPAddress.

+
+ Approve + Deny +
+
+} \ No newline at end of file diff --git a/ProjectLighthouse/Pages/ExternalAuth/AuthenticationPage.cshtml.cs b/ProjectLighthouse/Pages/ExternalAuth/AuthenticationPage.cshtml.cs new file mode 100644 index 00000000..7af46f46 --- /dev/null +++ b/ProjectLighthouse/Pages/ExternalAuth/AuthenticationPage.cshtml.cs @@ -0,0 +1,30 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using LBPUnion.ProjectLighthouse.Helpers; +using LBPUnion.ProjectLighthouse.Pages.Layouts; +using LBPUnion.ProjectLighthouse.Types; +using Microsoft.AspNetCore.Mvc; + +namespace LBPUnion.ProjectLighthouse.Pages.ExternalAuth +{ + public class AuthenticationPage : BaseLayout + { + public AuthenticationPage(Database database) : base(database) + {} + + public List AuthenticationAttempts = new() + { + new AuthenticationAttempt + { + Platform = Platform.RPCS3, + Timestamp = TimestampHelper.Timestamp, + IPAddress = "127.0.0.1", + }, + }; + + public async Task OnGet() + { + return this.Page(); + } + } +} \ No newline at end of file diff --git a/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml b/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml index bc352fba..23384f3a 100644 --- a/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml +++ b/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml @@ -12,7 +12,8 @@ } else { - Model.NavigationItems.Add(new PageNavigationItem("Log out", "/logout")); + Model.NavigationItems.Add(new PageNavigationItem("Authentication", "/authentication")); + Model.NavigationItems.Add(new PageNavigationItem("Log out", "/logout")); // should always be last } } diff --git a/ProjectLighthouse/Types/AuthenticationAttempt.cs b/ProjectLighthouse/Types/AuthenticationAttempt.cs new file mode 100644 index 00000000..131ef50b --- /dev/null +++ b/ProjectLighthouse/Types/AuthenticationAttempt.cs @@ -0,0 +1,10 @@ +namespace LBPUnion.ProjectLighthouse.Types +{ + public class AuthenticationAttempt + { + public long Timestamp; + public Platform Platform; + public string IPAddress; + public GameToken GameToken; + } +} \ No newline at end of file diff --git a/ProjectLighthouse/Types/Platform.cs b/ProjectLighthouse/Types/Platform.cs new file mode 100644 index 00000000..d43c7085 --- /dev/null +++ b/ProjectLighthouse/Types/Platform.cs @@ -0,0 +1,8 @@ +namespace LBPUnion.ProjectLighthouse.Types +{ + public enum Platform + { + PS3, + RPCS3, + } +} \ No newline at end of file From f7cea5bec2d0918ccbb0e3983cc3513bac87c8bf Mon Sep 17 00:00:00 2001 From: jvyden Date: Sat, 20 Nov 2021 02:56:55 -0500 Subject: [PATCH 016/123] Pin footer to bottom of page --- .../Pages/ExternalAuth/AuthenticationPage.cshtml | 2 +- ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ProjectLighthouse/Pages/ExternalAuth/AuthenticationPage.cshtml b/ProjectLighthouse/Pages/ExternalAuth/AuthenticationPage.cshtml index f53deacf..9527c357 100644 --- a/ProjectLighthouse/Pages/ExternalAuth/AuthenticationPage.cshtml +++ b/ProjectLighthouse/Pages/ExternalAuth/AuthenticationPage.cshtml @@ -5,7 +5,7 @@ @{ Layout = "Layouts/BaseLayout"; } -
+

Authentication

@foreach (AuthenticationAttempt authAttempt in Model.AuthenticationAttempts) {
diff --git a/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml b/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml index 23384f3a..f6217ace 100644 --- a/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml +++ b/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml @@ -34,11 +34,14 @@ @RenderBody() -
+

Page generated by @GitVersionHelper.FullVersion

@if (GitVersionHelper.IsDirty) {

This page was generated using a modified version of Project Lighthouse. Please make sure you are properly disclosing the source code to any users who may be using this instance.

}
- \ No newline at end of file + +@* width: 100%; *@ +@* bottom: 0; *@ +@* position: fixed; *@ \ No newline at end of file From abfb1c4cd86f0a222ad14f148d7a1e9931e83444 Mon Sep 17 00:00:00 2001 From: LumaLivy <7350336+LumaLivy@users.noreply.github.com> Date: Sat, 20 Nov 2021 04:34:03 -0500 Subject: [PATCH 017/123] Remove pointless .asEnumerable() --- ProjectLighthouse/Controllers/ReviewController.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/ProjectLighthouse/Controllers/ReviewController.cs b/ProjectLighthouse/Controllers/ReviewController.cs index dc04da77..bea193d1 100644 --- a/ProjectLighthouse/Controllers/ReviewController.cs +++ b/ProjectLighthouse/Controllers/ReviewController.cs @@ -175,7 +175,6 @@ namespace LBPUnion.ProjectLighthouse.Controllers IEnumerable reviews = this.database.Reviews.Where(r => r.Reviewer.Username == username && r.Slot.GameVersion <= gameVersion) .Include(r => r.Reviewer) .Include(r => r.Slot) - .AsEnumerable() // performance? .OrderByDescending(r => r.Timestamp) .Skip(pageStart - 1) .Take(pageSize); From ed1eac696a11a3bfb2b477b0bfec4c153fcafecf Mon Sep 17 00:00:00 2001 From: LumaLivy <7350336+LumaLivy@users.noreply.github.com> Date: Sat, 20 Nov 2021 04:37:11 -0500 Subject: [PATCH 018/123] Fix error codes 403->400 --- ProjectLighthouse/Controllers/ReviewController.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ProjectLighthouse/Controllers/ReviewController.cs b/ProjectLighthouse/Controllers/ReviewController.cs index bea193d1..4525a43d 100644 --- a/ProjectLighthouse/Controllers/ReviewController.cs +++ b/ProjectLighthouse/Controllers/ReviewController.cs @@ -204,10 +204,10 @@ namespace LBPUnion.ProjectLighthouse.Controllers if (user == null) return this.StatusCode(403, ""); User? reviewer = await this.database.Users.FirstOrDefaultAsync(u => u.Username == username); - if (reviewer == null) return this.StatusCode(403, ""); + if (reviewer == null) return this.StatusCode(400, ""); Review? review = await this.database.Reviews.FirstOrDefaultAsync(r => r.SlotId == slotId && r.ReviewerId == reviewer.UserId); - if (review == null) return this.StatusCode(403, ""); + if (review == null) return this.StatusCode(400, ""); RatedReview? ratedReview = await this.database.RatedReviews.FirstOrDefaultAsync(r => r.ReviewId == review.ReviewId && r.UserId == user.UserId); if (ratedReview == null) From d36a7d576560517cecfc6260661c681a5caf82be Mon Sep 17 00:00:00 2001 From: LumaLivy <7350336+LumaLivy@users.noreply.github.com> Date: Sat, 20 Nov 2021 04:39:53 -0500 Subject: [PATCH 019/123] Use better null/empty check --- ProjectLighthouse/Controllers/UserController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ProjectLighthouse/Controllers/UserController.cs b/ProjectLighthouse/Controllers/UserController.cs index 2e6fc452..94a7da6a 100644 --- a/ProjectLighthouse/Controllers/UserController.cs +++ b/ProjectLighthouse/Controllers/UserController.cs @@ -40,7 +40,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers if (token == null) return this.StatusCode(403, ""); string? user = await this.GetSerializedUser(username, token.GameVersion); - if (user == "") return this.NotFound(); + if (string.IsNullOrEmpty(user)) return this.NotFound(); return this.Ok(user); } From ece00c218ede04b4226bf45bcc27fc4449c4e557 Mon Sep 17 00:00:00 2001 From: LumaLivy <7350336+LumaLivy@users.noreply.github.com> Date: Sat, 20 Nov 2021 04:48:49 -0500 Subject: [PATCH 020/123] Create DeletedBy enum --- ProjectLighthouse/Controllers/ReviewController.cs | 2 +- ProjectLighthouse/Types/DeletedBy.cs | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 ProjectLighthouse/Types/DeletedBy.cs diff --git a/ProjectLighthouse/Controllers/ReviewController.cs b/ProjectLighthouse/Controllers/ReviewController.cs index 4525a43d..690cdf2e 100644 --- a/ProjectLighthouse/Controllers/ReviewController.cs +++ b/ProjectLighthouse/Controllers/ReviewController.cs @@ -235,7 +235,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers if (review == null) return this.StatusCode(403, ""); review.Deleted = true; - review.DeletedBy = "level_author"; // other value is "moderator" + review.DeletedBy = DeletedBy.LevelAuthor; await this.database.SaveChangesAsync(); return this.Ok(); diff --git a/ProjectLighthouse/Types/DeletedBy.cs b/ProjectLighthouse/Types/DeletedBy.cs new file mode 100644 index 00000000..02d61ec0 --- /dev/null +++ b/ProjectLighthouse/Types/DeletedBy.cs @@ -0,0 +1,9 @@ +namespace LBPUnion.ProjectLighthouse.Types +{ + public static class DeletedBy + { + public static string Moderator { get => "moderator"; } + public static string LevelAuthor { get => "level_author"; } + // TODO: deletion types for comments (profile etc) + } +} \ No newline at end of file From b05ae76af58d5039ce2447bf7e166584457dc601 Mon Sep 17 00:00:00 2001 From: jvyden Date: Sun, 21 Nov 2021 01:29:14 -0500 Subject: [PATCH 021/123] Add fomantic and static files directory --- .idea/.idea.ProjectLighthouse/.idea/jsLibraryMappings.xml | 2 +- ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml | 7 +++---- ProjectLighthouse/Program.cs | 1 + ProjectLighthouse/Startup.cs | 2 ++ ProjectLighthouse/StaticFiles/css/styles.css | 0 5 files changed, 7 insertions(+), 5 deletions(-) create mode 100644 ProjectLighthouse/StaticFiles/css/styles.css diff --git a/.idea/.idea.ProjectLighthouse/.idea/jsLibraryMappings.xml b/.idea/.idea.ProjectLighthouse/.idea/jsLibraryMappings.xml index 923bf2ee..e0f60e14 100644 --- a/.idea/.idea.ProjectLighthouse/.idea/jsLibraryMappings.xml +++ b/.idea/.idea.ProjectLighthouse/.idea/jsLibraryMappings.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml b/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml index f6217ace..6e12bbd0 100644 --- a/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml +++ b/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml @@ -22,6 +22,8 @@ Project Lighthouse + +
- -@* width: 100%; *@ -@* bottom: 0; *@ -@* position: fixed; *@ \ No newline at end of file + \ No newline at end of file diff --git a/ProjectLighthouse/Program.cs b/ProjectLighthouse/Program.cs index 6b7a1a96..418f7be3 100644 --- a/ProjectLighthouse/Program.cs +++ b/ProjectLighthouse/Program.cs @@ -77,6 +77,7 @@ namespace LBPUnion.ProjectLighthouse webBuilder => { webBuilder.UseStartup(); + webBuilder.UseWebRoot("StaticFiles"); } ) .ConfigureLogging diff --git a/ProjectLighthouse/Startup.cs b/ProjectLighthouse/Startup.cs index 18dc9c03..8b0e61bb 100644 --- a/ProjectLighthouse/Startup.cs +++ b/ProjectLighthouse/Startup.cs @@ -157,6 +157,8 @@ namespace LBPUnion.ProjectLighthouse app.UseRouting(); + app.UseStaticFiles(); + app.UseEndpoints(endpoints => endpoints.MapControllers()); app.UseEndpoints(endpoints => endpoints.MapRazorPages()); } diff --git a/ProjectLighthouse/StaticFiles/css/styles.css b/ProjectLighthouse/StaticFiles/css/styles.css new file mode 100644 index 00000000..e69de29b From 08d8940db4bad94b7949323cdfbc27ea526b14a3 Mon Sep 17 00:00:00 2001 From: jvyden Date: Sun, 21 Nov 2021 02:11:28 -0500 Subject: [PATCH 022/123] Fomantic can make anything look good --- .../ExternalAuth/AuthenticationPage.cshtml | 12 +++-- .../Pages/Layouts/BaseLayout.cshtml | 52 ++++++++++++------- .../Pages/Layouts/BaseLayout.cshtml.cs | 2 +- ProjectLighthouse/StaticFiles/css/styles.css | 13 +++++ ProjectLighthouse/Types/PageNavigationItem.cs | 6 ++- 5 files changed, 61 insertions(+), 24 deletions(-) diff --git a/ProjectLighthouse/Pages/ExternalAuth/AuthenticationPage.cshtml b/ProjectLighthouse/Pages/ExternalAuth/AuthenticationPage.cshtml index 9527c357..618dc6fe 100644 --- a/ProjectLighthouse/Pages/ExternalAuth/AuthenticationPage.cshtml +++ b/ProjectLighthouse/Pages/ExternalAuth/AuthenticationPage.cshtml @@ -8,11 +8,15 @@

Authentication

@foreach (AuthenticationAttempt authAttempt in Model.AuthenticationAttempts) { -
-

A @authAttempt.Platform authentication request was logged at @authAttempt.Timestamp from the IP address @authAttempt.IPAddress.

+
+

A @authAttempt.Platform authentication request was logged at @authAttempt.Timestamp from the IP address @authAttempt.IPAddress.

} \ No newline at end of file diff --git a/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml b/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml index 6e12bbd0..9e553841 100644 --- a/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml +++ b/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml @@ -7,13 +7,13 @@ if (Model.User == null) { - Model.NavigationItems.Add(new PageNavigationItem("Register", "/register")); - Model.NavigationItems.Add(new PageNavigationItem("Log in", "/login")); + Model.NavigationItems.Add(new PageNavigationItem("Log in", "/login", "user alternate")); + Model.NavigationItems.Add(new PageNavigationItem("Register", "/register", "user alternate edit")); } else { - Model.NavigationItems.Add(new PageNavigationItem("Authentication", "/authentication")); - Model.NavigationItems.Add(new PageNavigationItem("Log out", "/logout")); // should always be last + Model.NavigationItems.Add(new PageNavigationItem("Authentication", "/authentication", "key")); + Model.NavigationItems.Add(new PageNavigationItem("Log out", "/logout", "user alternate slash")); // should always be last } } @@ -22,25 +22,41 @@ Project Lighthouse - +
- +
-@RenderBody() +
+
+ @RenderBody() +
-