diff --git a/ProjectLighthouse.Servers.Website/Pages/Layouts/BaseLayout.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/Layouts/BaseLayout.cshtml.cs index 93259557..1429e093 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Layouts/BaseLayout.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/Layouts/BaseLayout.cshtml.cs @@ -52,6 +52,8 @@ public class BaseLayout : PageModel { if (ServerStatics.IsUnitTesting) return LocalizationManager.DefaultLang; if (this.language != null) return this.language; + + if (this.User?.IsAPirate ?? false) return "en-PT"; IRequestCultureFeature? requestCulture = Request.HttpContext.Features.Get(); if (requestCulture == null) return this.language = LocalizationManager.DefaultLang; diff --git a/ProjectLighthouse.Servers.Website/Pages/PirateSignupPage.cshtml b/ProjectLighthouse.Servers.Website/Pages/PirateSignupPage.cshtml new file mode 100644 index 00000000..9d9b183e --- /dev/null +++ b/ProjectLighthouse.Servers.Website/Pages/PirateSignupPage.cshtml @@ -0,0 +1,31 @@ +@page "/pirate" +@model LBPUnion.ProjectLighthouse.Servers.Website.Pages.PirateSignupPage + +@{ + Layout = "Layouts/BaseLayout"; + Model.Title = "ARRRRRRRRRR!"; +} + + +@if (!Model.User!.IsAPirate) +{ +

So, ye wanna be a pirate? Well, ye came to the right place!

+

Just click this 'ere button, and welcome aboard!

+

If you ever wanna walk the plank, come back 'ere.

+ +
+ @Html.AntiForgeryToken() + +
+} +else +{ +

Back so soon, aye?

+

If you're gonna walk the plank, then do it!

+ +
+ @Html.AntiForgeryToken() + +
+} + diff --git a/ProjectLighthouse.Servers.Website/Pages/PirateSignupPage.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/PirateSignupPage.cshtml.cs new file mode 100644 index 00000000..445aed21 --- /dev/null +++ b/ProjectLighthouse.Servers.Website/Pages/PirateSignupPage.cshtml.cs @@ -0,0 +1,32 @@ +using LBPUnion.ProjectLighthouse.PlayerData.Profiles; +using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; +using Microsoft.EntityFrameworkCore.Metadata.Internal; + +namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages; + +public class PirateSignupPage : BaseLayout +{ + public PirateSignupPage(Database database) : base(database) + {} + + public async Task OnGet() + { + User? user = this.Database.UserFromWebRequest(this.Request); + if (user == null) return this.RedirectToPage("/login"); + + return this.Page(); + } + + public async Task OnPost() + { + User? user = this.Database.UserFromWebRequest(this.Request); + if (user == null) return this.Redirect("/login"); + + user.IsAPirate = !user.IsAPirate; + await this.Database.SaveChangesAsync(); + + return this.Redirect("/"); + } +} \ No newline at end of file diff --git a/ProjectLighthouse.sln.DotSettings b/ProjectLighthouse.sln.DotSettings index 8cbc8651..ee49821a 100644 --- a/ProjectLighthouse.sln.DotSettings +++ b/ProjectLighthouse.sln.DotSettings @@ -101,6 +101,7 @@ True True True + True True True True diff --git a/ProjectLighthouse/Migrations/20220802150408_Arrrrrr.cs b/ProjectLighthouse/Migrations/20220802150408_Arrrrrr.cs new file mode 100644 index 00000000..43659add --- /dev/null +++ b/ProjectLighthouse/Migrations/20220802150408_Arrrrrr.cs @@ -0,0 +1,31 @@ +using System; +using LBPUnion.ProjectLighthouse; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace ProjectLighthouse.Migrations +{ + [DbContext(typeof(Database))] + [Migration("20220802150408_Arrrrrr")] + public partial class Arrrrrr : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "IsAPirate", + table: "Users", + type: "tinyint(1)", + nullable: false, + defaultValue: false); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "IsAPirate", + table: "Users"); + } + } +} diff --git a/ProjectLighthouse/Migrations/DatabaseModelSnapshot.cs b/ProjectLighthouse/Migrations/DatabaseModelSnapshot.cs index 494435fd..f2569a5f 100644 --- a/ProjectLighthouse/Migrations/DatabaseModelSnapshot.cs +++ b/ProjectLighthouse/Migrations/DatabaseModelSnapshot.cs @@ -292,8 +292,7 @@ namespace ProjectLighthouse.Migrations b.Property("TeamPick") .HasColumnType("tinyint(1)"); - b.Property("Type") - .IsRequired() + b.Property("Type") .HasColumnType("int"); b.HasKey("SlotId"); @@ -429,9 +428,6 @@ namespace ProjectLighthouse.Migrations b.Property("Created") .HasColumnType("datetime(6)"); - b.Property("ExpiresAt") - .HasColumnType("datetime(6)"); - b.Property("ResetToken") .HasColumnType("longtext"); @@ -686,6 +682,9 @@ namespace ProjectLighthouse.Migrations b.Property("IconHash") .HasColumnType("longtext"); + b.Property("IsAPirate") + .HasColumnType("tinyint(1)"); + b.Property("IsAdmin") .HasColumnType("tinyint(1)"); @@ -755,9 +754,6 @@ namespace ProjectLighthouse.Migrations b.Property("Created") .HasColumnType("datetime(6)"); - b.Property("ExpiresAt") - .HasColumnType("datetime(6)"); - b.Property("Token") .HasColumnType("longtext"); diff --git a/ProjectLighthouse/PlayerData/Profiles/User.cs b/ProjectLighthouse/PlayerData/Profiles/User.cs index f70d1ee0..b9127577 100644 --- a/ProjectLighthouse/PlayerData/Profiles/User.cs +++ b/ProjectLighthouse/PlayerData/Profiles/User.cs @@ -147,6 +147,11 @@ public class User [JsonIgnore] public string? ApprovedIPAddress { get; set; } #nullable disable + + /// + /// ARRR! Forces the user to see Pirate English translations on the website. + /// + public bool IsAPirate { get; set; } public string Serialize(GameVersion gameVersion = GameVersion.LittleBigPlanet1) {