mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-26 23:18:39 +00:00
Implement checking for the Patchwork user agent, move logout into standalone method
This commit is contained in:
parent
df7ebf977a
commit
68dbf50253
7 changed files with 72 additions and 8 deletions
|
@ -1,4 +1,5 @@
|
|||
using System.Text;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using LBPUnion.ProjectLighthouse.Configuration;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Extensions;
|
||||
|
@ -7,6 +8,7 @@ using LBPUnion.ProjectLighthouse.Localization;
|
|||
using LBPUnion.ProjectLighthouse.Localization.StringLists;
|
||||
using LBPUnion.ProjectLighthouse.Logging;
|
||||
using LBPUnion.ProjectLighthouse.Serialization;
|
||||
using LBPUnion.ProjectLighthouse.Servers.GameServer.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Notifications;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Token;
|
||||
|
@ -54,6 +56,10 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.";
|
|||
public async Task<IActionResult> Announce()
|
||||
{
|
||||
GameTokenEntity token = this.GetToken();
|
||||
UserEntity? user = await this.database.UserFromGameToken(token);
|
||||
|
||||
if (user == null)
|
||||
return this.Forbid();
|
||||
|
||||
string username = await this.database.UsernameFromGameToken(token);
|
||||
|
||||
|
@ -67,6 +73,18 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.";
|
|||
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(user.UserAgent))
|
||||
{
|
||||
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
|
||||
announceText.Append("\n\n---DEBUG INFO---\n" +
|
||||
$"user.UserId: {token.UserId}\n" +
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue