mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-28 16:08:38 +00:00
403 user at login instead of logging out at /announce
This commit is contained in:
parent
0c8ff50176
commit
b84bf02373
4 changed files with 11 additions and 36 deletions
|
@ -3,6 +3,7 @@ using LBPUnion.ProjectLighthouse.Configuration;
|
||||||
using LBPUnion.ProjectLighthouse.Database;
|
using LBPUnion.ProjectLighthouse.Database;
|
||||||
using LBPUnion.ProjectLighthouse.Extensions;
|
using LBPUnion.ProjectLighthouse.Extensions;
|
||||||
using LBPUnion.ProjectLighthouse.Helpers;
|
using LBPUnion.ProjectLighthouse.Helpers;
|
||||||
|
using LBPUnion.ProjectLighthouse.Servers.GameServer.Helpers;
|
||||||
using LBPUnion.ProjectLighthouse.Logging;
|
using LBPUnion.ProjectLighthouse.Logging;
|
||||||
using LBPUnion.ProjectLighthouse.Tickets;
|
using LBPUnion.ProjectLighthouse.Tickets;
|
||||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||||
|
@ -66,6 +67,11 @@ public class LoginController : ControllerBase
|
||||||
|
|
||||||
UserEntity? user;
|
UserEntity? user;
|
||||||
|
|
||||||
|
if (!PatchworkHelper.UserHasValidPatchworkUserAgent(this.Request.Headers.UserAgent.ToString()))
|
||||||
|
{
|
||||||
|
return this.Forbid();
|
||||||
|
}
|
||||||
|
|
||||||
switch (npTicket.Platform)
|
switch (npTicket.Platform)
|
||||||
{
|
{
|
||||||
case Platform.RPCS3:
|
case Platform.RPCS3:
|
||||||
|
@ -214,6 +220,8 @@ public class LoginController : ControllerBase
|
||||||
|
|
||||||
Logger.Success($"Successfully logged in user {user.Username} as {token.GameVersion} client", LogArea.Login);
|
Logger.Success($"Successfully logged in user {user.Username} as {token.GameVersion} client", LogArea.Login);
|
||||||
|
|
||||||
|
user.LastLogin = TimeHelper.TimestampMillis;
|
||||||
|
|
||||||
await database.SaveChangesAsync();
|
await database.SaveChangesAsync();
|
||||||
|
|
||||||
// Create a new room on LBP2/3/Vita
|
// Create a new room on LBP2/3/Vita
|
||||||
|
|
|
@ -31,12 +31,12 @@ public class LogoutController : ControllerBase
|
||||||
UserEntity? user = await this.database.UserFromGameToken(token);
|
UserEntity? user = await this.database.UserFromGameToken(token);
|
||||||
if (user == null) return this.Forbid();
|
if (user == null) return this.Forbid();
|
||||||
|
|
||||||
await LogoutHelper.Logout(token, user, database);
|
user.LastLogout = TimeHelper.TimestampMillis;
|
||||||
|
|
||||||
user.LastLogin = TimeHelper.TimestampMillis;
|
await this.database.GameTokens.RemoveWhere(t => t.TokenId == token.TokenId);
|
||||||
|
await this.database.LastContacts.RemoveWhere(c => c.UserId == token.UserId);
|
||||||
|
|
||||||
return this.Ok();
|
return this.Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,4 +1,3 @@
|
||||||
using System.Globalization;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using LBPUnion.ProjectLighthouse.Configuration;
|
using LBPUnion.ProjectLighthouse.Configuration;
|
||||||
using LBPUnion.ProjectLighthouse.Database;
|
using LBPUnion.ProjectLighthouse.Database;
|
||||||
|
@ -8,7 +7,6 @@ using LBPUnion.ProjectLighthouse.Localization;
|
||||||
using LBPUnion.ProjectLighthouse.Localization.StringLists;
|
using LBPUnion.ProjectLighthouse.Localization.StringLists;
|
||||||
using LBPUnion.ProjectLighthouse.Logging;
|
using LBPUnion.ProjectLighthouse.Logging;
|
||||||
using LBPUnion.ProjectLighthouse.Serialization;
|
using LBPUnion.ProjectLighthouse.Serialization;
|
||||||
using LBPUnion.ProjectLighthouse.Servers.GameServer.Helpers;
|
|
||||||
using LBPUnion.ProjectLighthouse.Types.Entities.Notifications;
|
using LBPUnion.ProjectLighthouse.Types.Entities.Notifications;
|
||||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||||
using LBPUnion.ProjectLighthouse.Types.Entities.Token;
|
using LBPUnion.ProjectLighthouse.Types.Entities.Token;
|
||||||
|
@ -73,19 +71,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.";
|
||||||
announceText.Insert(0, BaseLayoutStrings.ReadOnlyWarn.Translate(LocalizationManager.DefaultLang) + "\n\n");
|
announceText.Insert(0, BaseLayoutStrings.ReadOnlyWarn.Translate(LocalizationManager.DefaultLang) + "\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ServerConfiguration.Instance.RequirePatchworkUserAgent)
|
|
||||||
{
|
|
||||||
announceText.Append("This server instance requires the use of the Patchwork plugin for LBP.\n\n");
|
|
||||||
|
|
||||||
if (!PatchworkHelper.UserHasValidPatchworkUserAgent(this.Request.Headers.UserAgent.ToString()))
|
|
||||||
{
|
|
||||||
announceText.Append("It appears you do not have the Patchwork plugin installed correctly." +
|
|
||||||
"Since this server instance requires it, you will not be able to play until you so.");
|
|
||||||
|
|
||||||
await LogoutHelper.Logout(token, user, database);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
announceText.Append("\n\n---DEBUG INFO---\n" +
|
announceText.Append("\n\n---DEBUG INFO---\n" +
|
||||||
$"user.UserId: {token.UserId}\n" +
|
$"user.UserId: {token.UserId}\n" +
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
using LBPUnion.ProjectLighthouse.Helpers;
|
|
||||||
using LBPUnion.ProjectLighthouse.Database;
|
|
||||||
using LBPUnion.ProjectLighthouse.Extensions;
|
|
||||||
using LBPUnion.ProjectLighthouse.Types.Entities.Token;
|
|
||||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
|
||||||
|
|
||||||
namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Helpers;
|
|
||||||
|
|
||||||
public class LogoutHelper
|
|
||||||
{
|
|
||||||
public static async Task Logout(GameTokenEntity token, UserEntity user, DatabaseContext database)
|
|
||||||
{
|
|
||||||
user.LastLogout = TimeHelper.TimestampMillis;
|
|
||||||
|
|
||||||
await database.GameTokens.RemoveWhere(t => t.TokenId == token.TokenId);
|
|
||||||
await database.LastContacts.RemoveWhere(c => c.UserId == token.UserId);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue