diff --git a/ProjectLighthouse.Localization/Register.resx b/ProjectLighthouse.Localization/Register.resx
index 15a1183e..e6eb08fc 100644
--- a/ProjectLighthouse.Localization/Register.resx
+++ b/ProjectLighthouse.Localization/Register.resx
@@ -21,4 +21,7 @@
Caution: Your username MUST match your PSN/RPCN username in order to be able to sign in from in-game.
+
+ The game will be read-only until you verify your email
+
\ No newline at end of file
diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/CommentController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/CommentController.cs
index 7e3baeb9..53e0afca 100644
--- a/ProjectLighthouse.Servers.GameServer/Controllers/CommentController.cs
+++ b/ProjectLighthouse.Servers.GameServer/Controllers/CommentController.cs
@@ -3,6 +3,7 @@ using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Helpers;
+using LBPUnion.ProjectLighthouse.Servers.GameServer.Middlewares;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
using LBPUnion.ProjectLighthouse.Types.Entities.Token;
using LBPUnion.ProjectLighthouse.Types.Filter;
@@ -29,6 +30,7 @@ public class CommentController : ControllerBase
[HttpPost("rateUserComment/{username}")]
[HttpPost("rateComment/{slotType}/{slotId:int}")]
+ [EmailVerification]
public async Task RateComment([FromQuery] int commentId, [FromQuery] int rating, string? username, string? slotType, int slotId)
{
GameTokenEntity token = this.GetToken();
@@ -113,6 +115,7 @@ public class CommentController : ControllerBase
[HttpPost("postUserComment/{username}")]
[HttpPost("postComment/{slotType}/{slotId:int}")]
+ [EmailVerification]
public async Task PostComment(string? username, string? slotType, int slotId)
{
GameTokenEntity token = this.GetToken();
@@ -152,6 +155,7 @@ public class CommentController : ControllerBase
[HttpPost("deleteUserComment/{username}")]
[HttpPost("deleteComment/{slotType}/{slotId:int}")]
+ [EmailVerification]
public async Task DeleteComment([FromQuery] int commentId, string? username, string? slotType, int slotId)
{
GameTokenEntity token = this.GetToken();
diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/FriendsController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/FriendsController.cs
index 83e198d8..49c1df81 100644
--- a/ProjectLighthouse.Servers.GameServer/Controllers/FriendsController.cs
+++ b/ProjectLighthouse.Servers.GameServer/Controllers/FriendsController.cs
@@ -1,6 +1,7 @@
#nullable enable
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions;
+using LBPUnion.ProjectLighthouse.Servers.GameServer.Middlewares;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Types.Users;
using LBPUnion.ProjectLighthouse.StorableLists.Stores;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
@@ -17,6 +18,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers;
[Authorize]
[Route("LITTLEBIGPLANETPS3_XML/")]
[Produces("text/xml")]
+[EmailVerification]
public class FriendsController : ControllerBase
{
private readonly DatabaseContext database;
diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/Login/ClientConfigurationController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/Login/ClientConfigurationController.cs
index f4ed348c..b2a5ba15 100644
--- a/ProjectLighthouse.Servers.GameServer/Controllers/Login/ClientConfigurationController.cs
+++ b/ProjectLighthouse.Servers.GameServer/Controllers/Login/ClientConfigurationController.cs
@@ -3,6 +3,7 @@ using System.Diagnostics.CodeAnalysis;
using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions;
+using LBPUnion.ProjectLighthouse.Servers.GameServer.Middlewares;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Types.Users;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
using LBPUnion.ProjectLighthouse.Types.Serialization;
@@ -70,6 +71,7 @@ public class ClientConfigurationController : ControllerBase
[HttpPost("privacySettings")]
[Produces("text/xml")]
+ [EmailVerification]
public async Task SetPrivacySetting()
{
UserEntity? user = await this.database.UserFromGameToken(this.GetToken());
diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/Matching/EnterLevelController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/Matching/EnterLevelController.cs
index e8b2aa37..0db8ad44 100644
--- a/ProjectLighthouse.Servers.GameServer/Controllers/Matching/EnterLevelController.cs
+++ b/ProjectLighthouse.Servers.GameServer/Controllers/Matching/EnterLevelController.cs
@@ -2,6 +2,7 @@
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Helpers;
+using LBPUnion.ProjectLighthouse.Servers.GameServer.Middlewares;
using LBPUnion.ProjectLighthouse.Types.Entities.Interaction;
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
using LBPUnion.ProjectLighthouse.Types.Entities.Token;
@@ -16,6 +17,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Matching;
[Authorize]
[Route("LITTLEBIGPLANETPS3_XML/")]
[Produces("text/xml")]
+[EmailVerification]
public class EnterLevelController : ControllerBase
{
private readonly DatabaseContext database;
diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/Matching/MatchController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/Matching/MatchController.cs
index 2b3b295b..53f46df8 100644
--- a/ProjectLighthouse.Servers.GameServer/Controllers/Matching/MatchController.cs
+++ b/ProjectLighthouse.Servers.GameServer/Controllers/Matching/MatchController.cs
@@ -5,6 +5,7 @@ using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Logging;
+using LBPUnion.ProjectLighthouse.Servers.GameServer.Middlewares;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
using LBPUnion.ProjectLighthouse.Types.Entities.Token;
using LBPUnion.ProjectLighthouse.Types.Logging;
@@ -21,6 +22,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Matching;
[Authorize]
[Route("LITTLEBIGPLANETPS3_XML/")]
[Produces("text/xml")]
+[EmailVerification]
public class MatchController : ControllerBase
{
private readonly DatabaseContext database;
diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/MessageController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/MessageController.cs
index cccc9b48..7093aa03 100644
--- a/ProjectLighthouse.Servers.GameServer/Controllers/MessageController.cs
+++ b/ProjectLighthouse.Servers.GameServer/Controllers/MessageController.cs
@@ -13,6 +13,7 @@ using LBPUnion.ProjectLighthouse.Types.Entities.Token;
using LBPUnion.ProjectLighthouse.Types.Filter;
using LBPUnion.ProjectLighthouse.Types.Logging;
using LBPUnion.ProjectLighthouse.Types.Mail;
+using LBPUnion.ProjectLighthouse.Types.Notifications;
using LBPUnion.ProjectLighthouse.Types.Serialization;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
@@ -96,6 +97,15 @@ along with this program. If not, see .";
StringBuilder builder = new();
+ UserEntity? user = await this.database.UserFromGameToken(token);
+ if (user?.EmailAddressVerified == false)
+ {
+ GameNotification verifyEmailNotification = new();
+ verifyEmailNotification.Type = NotificationType.ModerationNotification;
+ verifyEmailNotification.Text = LocalizationManager.GetLocalizedString(TranslationAreas.Register, user.Language, "email_verify_notice");
+ builder.AppendLine(LighthouseSerializer.Serialize(this.HttpContext.RequestServices, verifyEmailNotification));
+ }
+
foreach (NotificationEntity notification in notifications)
{
builder.AppendLine(LighthouseSerializer.Serialize(this.HttpContext.RequestServices,
diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/ReportController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/ReportController.cs
index bf5007c3..2e53dd9c 100644
--- a/ProjectLighthouse.Servers.GameServer/Controllers/ReportController.cs
+++ b/ProjectLighthouse.Servers.GameServer/Controllers/ReportController.cs
@@ -5,6 +5,7 @@ using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Files;
using LBPUnion.ProjectLighthouse.Helpers;
+using LBPUnion.ProjectLighthouse.Servers.GameServer.Middlewares;
using LBPUnion.ProjectLighthouse.Types.Entities.Moderation;
using LBPUnion.ProjectLighthouse.Types.Entities.Token;
using LBPUnion.ProjectLighthouse.Types.Moderation.Reports;
@@ -18,6 +19,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers;
[Authorize]
[Route("LITTLEBIGPLANETPS3_XML/")]
[Produces("text/xml")]
+[EmailVerification]
public class ReportController : ControllerBase
{
private readonly DatabaseContext database;
diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/Resources/PhotosController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/Resources/PhotosController.cs
index 4c73d0a0..2056ba1d 100644
--- a/ProjectLighthouse.Servers.GameServer/Controllers/Resources/PhotosController.cs
+++ b/ProjectLighthouse.Servers.GameServer/Controllers/Resources/PhotosController.cs
@@ -6,6 +6,7 @@ using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Files;
using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Logging;
+using LBPUnion.ProjectLighthouse.Servers.GameServer.Middlewares;
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
using LBPUnion.ProjectLighthouse.Types.Entities.Token;
@@ -33,6 +34,7 @@ public class PhotosController : ControllerBase
}
[HttpPost("uploadPhoto")]
+ [EmailVerification]
public async Task UploadPhoto()
{
GameTokenEntity token = this.GetToken();
@@ -234,6 +236,7 @@ public class PhotosController : ControllerBase
}
[HttpPost("deletePhoto/{id:int}")]
+ [EmailVerification]
public async Task DeletePhoto(int id)
{
GameTokenEntity token = this.GetToken();
diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/Resources/ResourcesController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/Resources/ResourcesController.cs
index 7231ccaf..8a2995eb 100644
--- a/ProjectLighthouse.Servers.GameServer/Controllers/Resources/ResourcesController.cs
+++ b/ProjectLighthouse.Servers.GameServer/Controllers/Resources/ResourcesController.cs
@@ -1,9 +1,9 @@
-#nullable enable
using System.Text;
using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Files;
using LBPUnion.ProjectLighthouse.Logging;
+using LBPUnion.ProjectLighthouse.Servers.GameServer.Middlewares;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Types.Misc;
using LBPUnion.ProjectLighthouse.Types.Logging;
using LBPUnion.ProjectLighthouse.Types.Resources;
@@ -52,6 +52,7 @@ public class ResourcesController : ControllerBase
[HttpPost("upload/{hash}/unattributed")]
[HttpPost("upload/{hash}")]
+ [EmailVerification]
public async Task UploadResource(string hash)
{
string assetsDirectory = FileHelper.ResourcePath;
diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/Slots/LevelTagsController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/Slots/LevelTagsController.cs
index 2b069099..34975c0e 100644
--- a/ProjectLighthouse.Servers.GameServer/Controllers/Slots/LevelTagsController.cs
+++ b/ProjectLighthouse.Servers.GameServer/Controllers/Slots/LevelTagsController.cs
@@ -1,6 +1,7 @@
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Helpers;
+using LBPUnion.ProjectLighthouse.Servers.GameServer.Middlewares;
using LBPUnion.ProjectLighthouse.Types.Entities.Interaction;
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
using LBPUnion.ProjectLighthouse.Types.Entities.Token;
@@ -41,6 +42,7 @@ public class LevelTagsController : ControllerBase
}
[HttpPost("tag/{slotType}/{id:int}")]
+ [EmailVerification]
public async Task PostTag([FromForm(Name = "t")] string tagName, [FromRoute] string slotType, [FromRoute] int id)
{
GameTokenEntity token = this.GetToken();
diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/Slots/PlaylistController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/Slots/PlaylistController.cs
index 4763708a..69ff9dde 100644
--- a/ProjectLighthouse.Servers.GameServer/Controllers/Slots/PlaylistController.cs
+++ b/ProjectLighthouse.Servers.GameServer/Controllers/Slots/PlaylistController.cs
@@ -2,6 +2,7 @@
using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions;
+using LBPUnion.ProjectLighthouse.Servers.GameServer.Middlewares;
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
using LBPUnion.ProjectLighthouse.Types.Entities.Token;
using LBPUnion.ProjectLighthouse.Types.Serialization;
@@ -41,6 +42,7 @@ public class PlaylistController : ControllerBase
}
[HttpPost("playlists/{playlistId:int}/delete")]
+ [EmailVerification]
public async Task DeletePlaylist(int playlistId)
{
GameTokenEntity token = this.GetToken();
@@ -60,6 +62,7 @@ public class PlaylistController : ControllerBase
[HttpPost("playlists/{playlistId:int}/slots")]
[HttpPost("playlists/{playlistId:int}/slots/{slotId:int}/delete")]
[HttpPost("playlists/{playlistId:int}/order_slots")]
+ [EmailVerification]
public async Task UpdatePlaylist(int playlistId, int slotId)
{
GameTokenEntity token = this.GetToken();
@@ -124,6 +127,7 @@ public class PlaylistController : ControllerBase
}
[HttpPost("playlists")]
+ [EmailVerification]
public async Task CreatePlaylist()
{
GameTokenEntity token = this.GetToken();
diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/Slots/PublishController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/Slots/PublishController.cs
index dfb42c71..7d0b7fc1 100644
--- a/ProjectLighthouse.Servers.GameServer/Controllers/Slots/PublishController.cs
+++ b/ProjectLighthouse.Servers.GameServer/Controllers/Slots/PublishController.cs
@@ -6,6 +6,7 @@ using LBPUnion.ProjectLighthouse.Files;
using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Logging;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Helpers;
+using LBPUnion.ProjectLighthouse.Servers.GameServer.Middlewares;
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
using LBPUnion.ProjectLighthouse.Types.Entities.Token;
@@ -24,6 +25,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Slots;
[Authorize]
[Route("LITTLEBIGPLANETPS3_XML/")]
[Produces("text/xml")]
+[EmailVerification]
public class PublishController : ControllerBase
{
private readonly DatabaseContext database;
diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/Slots/ReviewController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/Slots/ReviewController.cs
index 3b2a7fbb..ee83e8e3 100644
--- a/ProjectLighthouse.Servers.GameServer/Controllers/Slots/ReviewController.cs
+++ b/ProjectLighthouse.Servers.GameServer/Controllers/Slots/ReviewController.cs
@@ -3,6 +3,7 @@ using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Helpers;
+using LBPUnion.ProjectLighthouse.Servers.GameServer.Middlewares;
using LBPUnion.ProjectLighthouse.Types.Entities.Interaction;
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
using LBPUnion.ProjectLighthouse.Types.Entities.Token;
@@ -29,6 +30,7 @@ public class ReviewController : ControllerBase
// LBP1 rating
[HttpPost("rate/user/{slotId:int}")]
+ [EmailVerification]
public async Task Rate(int slotId, int rating)
{
GameTokenEntity token = this.GetToken();
@@ -58,6 +60,7 @@ public class ReviewController : ControllerBase
// LBP2 and beyond rating
[HttpPost("dpadrate/user/{slotId:int}")]
+ [EmailVerification]
public async Task DPadRate(int slotId, int rating)
{
GameTokenEntity token = this.GetToken();
@@ -89,6 +92,7 @@ public class ReviewController : ControllerBase
}
[HttpPost("postReview/user/{slotId:int}")]
+ [EmailVerification]
public async Task PostReview(int slotId)
{
GameTokenEntity token = this.GetToken();
@@ -202,6 +206,7 @@ public class ReviewController : ControllerBase
}
[HttpPost("rateReview/user/{slotId:int}/{username}")]
+ [EmailVerification]
public async Task RateReview(int slotId, string username, int rating = 0)
{
GameTokenEntity token = this.GetToken();
@@ -255,6 +260,7 @@ public class ReviewController : ControllerBase
}
[HttpPost("deleteReview/user/{slotId:int}/{username}")]
+ [EmailVerification]
public async Task DeleteReview(int slotId, string username)
{
GameTokenEntity token = this.GetToken();
diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/Slots/ScoreController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/Slots/ScoreController.cs
index a7c41dd6..a789cc24 100644
--- a/ProjectLighthouse.Servers.GameServer/Controllers/Slots/ScoreController.cs
+++ b/ProjectLighthouse.Servers.GameServer/Controllers/Slots/ScoreController.cs
@@ -3,6 +3,7 @@ using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Logging;
+using LBPUnion.ProjectLighthouse.Servers.GameServer.Middlewares;
using LBPUnion.ProjectLighthouse.StorableLists.Stores;
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
@@ -42,6 +43,7 @@ public class ScoreController : ControllerBase
[HttpPost("scoreboard/{slotType}/{id:int}")]
[HttpPost("scoreboard/{slotType}/{id:int}/{childId:int}")]
+ [EmailVerification]
public async Task SubmitScore(string slotType, int id, int childId)
{
GameTokenEntity token = this.GetToken();
diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/UserController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/UserController.cs
index 7301bc52..34254f23 100644
--- a/ProjectLighthouse.Servers.GameServer/Controllers/UserController.cs
+++ b/ProjectLighthouse.Servers.GameServer/Controllers/UserController.cs
@@ -6,6 +6,7 @@ using LBPUnion.ProjectLighthouse.Files;
using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Logging;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Helpers;
+using LBPUnion.ProjectLighthouse.Servers.GameServer.Middlewares;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Types.Users;
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
@@ -63,6 +64,7 @@ public class UserController : ControllerBase
}
[HttpPost("updateUser")]
+ [EmailVerification]
public async Task UpdateUser()
{
GameTokenEntity token = this.GetToken();
@@ -171,6 +173,7 @@ public class UserController : ControllerBase
[HttpPost("update_my_pins")]
[Produces("text/json")]
+ [EmailVerification]
public async Task UpdateMyPins()
{
UserEntity? user = await this.database.UserFromGameToken(this.GetToken());
diff --git a/ProjectLighthouse.Servers.GameServer/Middlewares/EmailVerificationMiddleware.cs b/ProjectLighthouse.Servers.GameServer/Middlewares/EmailVerificationMiddleware.cs
index 15127419..d7c14375 100644
--- a/ProjectLighthouse.Servers.GameServer/Middlewares/EmailVerificationMiddleware.cs
+++ b/ProjectLighthouse.Servers.GameServer/Middlewares/EmailVerificationMiddleware.cs
@@ -1,57 +1,30 @@
-using System.Diagnostics;
+using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Middlewares;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
using LBPUnion.ProjectLighthouse.Types.Entities.Token;
+using Microsoft.AspNetCore.Http.Features;
namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Middlewares;
+public class EmailVerificationAttribute : Attribute;
+
public class EmailVerificationMiddleware: MiddlewareDBContext
{
- private readonly bool requireVerification;
- private static readonly HashSet verifyPathList =
- [
- "uploadPhoto",
- "deletePhoto",
- "upload",
- "publish",
- "rateUserComment",
- "rateComment",
- "postUserComment",
- "postComment",
- "deleteUserComment",
- "deleteComment",
- "npdata",
- "grief",
- "updateUser",
- "update_my_pins",
- "match",
- "play",
- "enterLevel",
- "startPublish",
- ];
-
- public EmailVerificationMiddleware(RequestDelegate next, bool requireVerification) : base(next)
+ public EmailVerificationMiddleware(RequestDelegate next) : base(next)
{
- this.requireVerification = requireVerification;
+
}
public override async Task InvokeAsync(HttpContext context, DatabaseContext database)
{
- if (requireVerification)
+ if (ServerConfiguration.Instance.Mail.RequireEmailVerification)
{
- if (context.Request.Path.Value == null)
- {
- await this.next(context);
- return;
- }
-
- const string url = "/LITTLEBIGPLANETPS3_XML";
- string verifyPath = context.Request.Path;
- string strippedPath = verifyPath.Contains(url) ? verifyPath[url.Length..].Split("/")[0] : "";
+ Endpoint? endpoint = context.Features.Get()?.Endpoint;
+ EmailVerificationAttribute? attribute = endpoint?.Metadata.GetMetadata();
- if (verifyPathList.Contains(strippedPath))
+ if (attribute != null)
{
GameTokenEntity? gameToken = await database.GameTokenFromRequest(context.Request);
if (gameToken == null)
@@ -63,7 +36,7 @@ public class EmailVerificationMiddleware: MiddlewareDBContext
UserEntity? user = await database.UserFromGameToken(gameToken);
if (!user!.EmailAddressVerified)
{
- context.Response.StatusCode = 403;
+ context.Response.StatusCode = 401; // 403 will cause a re-auth
context.Abort();
return;
}
diff --git a/ProjectLighthouse.Servers.GameServer/Startup/GameServerStartup.cs b/ProjectLighthouse.Servers.GameServer/Startup/GameServerStartup.cs
index 0d372e8f..b37b5d14 100644
--- a/ProjectLighthouse.Servers.GameServer/Startup/GameServerStartup.cs
+++ b/ProjectLighthouse.Servers.GameServer/Startup/GameServerStartup.cs
@@ -106,6 +106,7 @@ public class GameServerStartup
app.UseMiddleware();
app.UseMiddleware();
app.UseMiddleware(computeDigests);
+ app.UseMiddleware();
app.UseMiddleware();
app.UseRouting();
diff --git a/ProjectLighthouse/Configuration/ConfigurationCategories/MailConfiguration.cs b/ProjectLighthouse/Configuration/ConfigurationCategories/MailConfiguration.cs
index 8fa4c153..784ba15b 100644
--- a/ProjectLighthouse/Configuration/ConfigurationCategories/MailConfiguration.cs
+++ b/ProjectLighthouse/Configuration/ConfigurationCategories/MailConfiguration.cs
@@ -17,4 +17,6 @@ public class MailConfiguration
public string Password { get; set; } = "";
public bool UseSSL { get; set; } = true;
+
+ public bool RequireEmailVerification { get; set; } = true;
}
\ No newline at end of file