Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ProjectLighthouse.Localization/Register.resx
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@
<data name="username_notice" xml:space="preserve">
<value>Caution: Your username MUST match your PSN/RPCN username in order to be able to sign in from in-game.</value>
</data>
<data name="email_verify_notice" xml:space="preserve">
<value>You do not have an email set on your account or you have not verified it. You can set an email by opening the text chat and typing "/setemail [youremail@example.com]" (do not include the brackets), then check your inbox for a verification email.</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace LBPUnion.ProjectLighthouse.Localization.StringLists;
public static class RegisterStrings
{
public static readonly TranslatableString UsernameNotice = create("username_notice");
public static readonly TranslatableString EmailVerificationNotice = create("email_verify_notice");

private static TranslatableString create(string key) => new(TranslationAreas.Register, key);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
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;
Expand All @@ -29,6 +30,7 @@ public CommentController(DatabaseContext database)

[HttpPost("rateUserComment/{username}")]
[HttpPost("rateComment/{slotType}/{slotId:int}")]
[EmailVerification]
public async Task<IActionResult> RateComment([FromQuery] int commentId, [FromQuery] int rating, string? username, string? slotType, int slotId)
{
GameTokenEntity token = this.GetToken();
Expand Down Expand Up @@ -113,6 +115,7 @@ from blockedProfile in this.database.BlockedProfiles

[HttpPost("postUserComment/{username}")]
[HttpPost("postComment/{slotType}/{slotId:int}")]
[EmailVerification]
public async Task<IActionResult> PostComment(string? username, string? slotType, int slotId)
{
GameTokenEntity token = this.GetToken();
Expand Down Expand Up @@ -152,6 +155,7 @@ public async Task<IActionResult> PostComment(string? username, string? slotType,

[HttpPost("deleteUserComment/{username}")]
[HttpPost("deleteComment/{slotType}/{slotId:int}")]
[EmailVerification]
public async Task<IActionResult> DeleteComment([FromQuery] int commentId, string? username, string? slotType, int slotId)
{
GameTokenEntity token = this.GetToken();
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
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;
Expand Down Expand Up @@ -70,6 +71,7 @@ public async Task<IActionResult> GetPrivacySettings()

[HttpPost("privacySettings")]
[Produces("text/xml")]
[EmailVerification]
public async Task<IActionResult> SetPrivacySetting()
{
UserEntity? user = await this.database.UserFromGameToken(this.GetToken());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Localization;
using LBPUnion.ProjectLighthouse.Localization.StringLists;
using LBPUnion.ProjectLighthouse.Logging;
using LBPUnion.ProjectLighthouse.Serialization;
Expand All @@ -13,6 +12,7 @@
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;
Expand Down Expand Up @@ -55,16 +55,23 @@ public async Task<IActionResult> Announce()
{
GameTokenEntity token = this.GetToken();

string username = await this.database.UsernameFromGameToken(token);
UserEntity? user = await this.database.UserFromGameToken(token);
if (user == null) return this.Forbid();

StringBuilder announceText = new(ServerConfiguration.Instance.AnnounceText);

announceText.Replace("%user", username);
announceText.Replace("%user", user.Username);
announceText.Replace("%id", token.UserId.ToString());

if (ServerConfiguration.Instance.Mail.RequireEmailVerification)
{
announceText.Insert(0,
RegisterStrings.EmailVerificationNotice.Translate(user.Language) + "\n\n");
}

if (ServerConfiguration.Instance.UserGeneratedContentLimits.ReadOnlyMode)
{
announceText.Insert(0, BaseLayoutStrings.ReadOnlyWarn.Translate(LocalizationManager.DefaultLang) + "\n\n");
announceText.Insert(0, BaseLayoutStrings.ReadOnlyWarn.Translate(user.Language) + "\n\n");
}

#if DEBUG
Expand Down Expand Up @@ -96,6 +103,15 @@ public async Task<IActionResult> Notification()

StringBuilder builder = new();

UserEntity? user = await this.database.UserFromGameToken(token);
if (user?.EmailAddressVerified == false)
{
GameNotification verifyEmailNotification = new();
verifyEmailNotification.Type = NotificationType.ModerationNotification;
verifyEmailNotification.Text = RegisterStrings.EmailVerificationNotice.Translate(user.Language);
builder.AppendLine(LighthouseSerializer.Serialize(this.HttpContext.RequestServices, verifyEmailNotification));
}

foreach (NotificationEntity notification in notifications)
{
builder.AppendLine(LighthouseSerializer.Serialize(this.HttpContext.RequestServices,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
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;
Expand Down Expand Up @@ -33,6 +34,7 @@ public PhotosController(DatabaseContext database)
}

[HttpPost("uploadPhoto")]
[EmailVerification]
public async Task<IActionResult> UploadPhoto()
{
GameTokenEntity token = this.GetToken();
Expand Down Expand Up @@ -234,6 +236,7 @@ public async Task<IActionResult> UserPhotosWith(string user)
}

[HttpPost("deletePhoto/{id:int}")]
[EmailVerification]
public async Task<IActionResult> DeletePhoto(int id)
{
GameTokenEntity token = this.GetToken();
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -52,6 +52,7 @@ public IActionResult GetResource(string hash)

[HttpPost("upload/{hash}/unattributed")]
[HttpPost("upload/{hash}")]
[EmailVerification]
public async Task<IActionResult> UploadResource(string hash)
{
string assetsDirectory = FileHelper.ResourcePath;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -41,6 +42,7 @@ public IActionResult Get()
}

[HttpPost("tag/{slotType}/{id:int}")]
[EmailVerification]
public async Task<IActionResult> PostTag([FromForm(Name = "t")] string tagName, [FromRoute] string slotType, [FromRoute] int id)
{
GameTokenEntity token = this.GetToken();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -41,6 +42,7 @@ public async Task<IActionResult> GetPlaylistSlots(int playlistId)
}

[HttpPost("playlists/{playlistId:int}/delete")]
[EmailVerification]
public async Task<IActionResult> DeletePlaylist(int playlistId)
{
GameTokenEntity token = this.GetToken();
Expand All @@ -60,6 +62,7 @@ public async Task<IActionResult> DeletePlaylist(int playlistId)
[HttpPost("playlists/{playlistId:int}/slots")]
[HttpPost("playlists/{playlistId:int}/slots/{slotId:int}/delete")]
[HttpPost("playlists/{playlistId:int}/order_slots")]
[EmailVerification]
public async Task<IActionResult> UpdatePlaylist(int playlistId, int slotId)
{
GameTokenEntity token = this.GetToken();
Expand Down Expand Up @@ -124,6 +127,7 @@ private async Task<PlaylistResponse> GetUserPlaylists(int userId)
}

[HttpPost("playlists")]
[EmailVerification]
public async Task<IActionResult> CreatePlaylist()
{
GameTokenEntity token = this.GetToken();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,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;
Expand All @@ -29,6 +30,7 @@ public ReviewController(DatabaseContext database)

// LBP1 rating
[HttpPost("rate/user/{slotId:int}")]
[EmailVerification]
public async Task<IActionResult> Rate(int slotId, int rating)
{
GameTokenEntity token = this.GetToken();
Expand Down Expand Up @@ -58,6 +60,7 @@ public async Task<IActionResult> Rate(int slotId, int rating)

// LBP2 and beyond rating
[HttpPost("dpadrate/user/{slotId:int}")]
[EmailVerification]
public async Task<IActionResult> DPadRate(int slotId, int rating)
{
GameTokenEntity token = this.GetToken();
Expand Down Expand Up @@ -89,6 +92,7 @@ public async Task<IActionResult> DPadRate(int slotId, int rating)
}

[HttpPost("postReview/user/{slotId:int}")]
[EmailVerification]
public async Task<IActionResult> PostReview(int slotId)
{
GameTokenEntity token = this.GetToken();
Expand Down Expand Up @@ -202,6 +206,7 @@ public async Task<IActionResult> ReviewsBy(string username)
}

[HttpPost("rateReview/user/{slotId:int}/{username}")]
[EmailVerification]
public async Task<IActionResult> RateReview(int slotId, string username, int rating = 0)
{
GameTokenEntity token = this.GetToken();
Expand Down Expand Up @@ -255,6 +260,7 @@ public async Task<IActionResult> RateReview(int slotId, string username, int rat
}

[HttpPost("deleteReview/user/{slotId:int}/{username}")]
[EmailVerification]
public async Task<IActionResult> DeleteReview(int slotId, string username)
{
GameTokenEntity token = this.GetToken();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
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;
Expand Down Expand Up @@ -42,6 +43,7 @@ private static int[] GetFriendIds(int userId)

[HttpPost("scoreboard/{slotType}/{id:int}")]
[HttpPost("scoreboard/{slotType}/{id:int}/{childId:int}")]
[EmailVerification]
public async Task<IActionResult> SubmitScore(string slotType, int id, int childId)
{
GameTokenEntity token = this.GetToken();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
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;
Expand Down Expand Up @@ -63,6 +64,7 @@ public async Task<IActionResult> GetUserAlt([FromQuery(Name = "u")] string[] use
}

[HttpPost("updateUser")]
[EmailVerification]
public async Task<IActionResult> UpdateUser()
{
GameTokenEntity token = this.GetToken();
Expand Down Expand Up @@ -171,6 +173,7 @@ public async Task<IActionResult> UpdateUser()

[HttpPost("update_my_pins")]
[Produces("text/json")]
[EmailVerification]
public async Task<IActionResult> UpdateMyPins()
{
UserEntity? user = await this.database.UserFromGameToken(this.GetToken());
Expand Down
Loading
Loading