Allow more customization of the eula & announce screens

This commit is contained in:
jvyden 2022-01-09 22:41:39 -05:00
commit 11297b3f06
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278
2 changed files with 17 additions and 6 deletions

View file

@ -28,7 +28,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers
User? user = await this.database.UserFromGameRequest(this.Request);
if (user == null) return this.StatusCode(403, "");
return this.Ok(ServerSettings.Instance.EulaText + "\n" + $"{EulaHelper.License}\n");
return this.Ok($"{EulaHelper.License}\n{ServerSettings.Instance.EulaText}");
}
[HttpGet("announce")]
@ -47,19 +47,24 @@ namespace LBPUnion.ProjectLighthouse.Controllers
GameToken gameToken = userAndToken.Value.Item2;
#endif
string announceText = ServerSettings.Instance.AnnounceText;
announceText = announceText.Replace("%user", user.Username);
announceText = announceText.Replace("%id", user.UserId.ToString());
return this.Ok
(
$"You are now logged in as {user.Username}.\n\n" +
announceText +
#if DEBUG
"---DEBUG INFO---\n" +
"\n\n---DEBUG INFO---\n" +
$"user.UserId: {user.UserId}\n" +
$"token.Approved: {gameToken.Approved}\n" +
$"token.Used: {gameToken.Used}\n" +
$"token.UserLocation: {gameToken.UserLocation}\n" +
$"token.GameVersion: {gameToken.GameVersion}\n" +
"---DEBUG INFO---\n\n" +
"---DEBUG INFO---" +
#endif
ServerSettings.Instance.EulaText
"\n"
);
}

View file

@ -12,7 +12,7 @@ namespace LBPUnion.ProjectLighthouse.Types.Settings
public class ServerSettings
{
public const int CurrentConfigVersion = 13; // MUST BE INCREMENTED FOR EVERY CONFIG CHANGE!
public const int CurrentConfigVersion = 14; // MUST BE INCREMENTED FOR EVERY CONFIG CHANGE!
static ServerSettings()
{
if (ServerStatics.IsUnitTesting) return; // Unit testing, we don't want to read configurations here since the tests will provide their own
@ -74,6 +74,12 @@ namespace LBPUnion.ProjectLighthouse.Types.Settings
public string EulaText { get; set; } = "";
#if !DEBUG
public string AnnounceText { get; set; } = "You are now logged in as %user.";
#else
public string AnnounceText { get; set; } = "You are now logged in as %user (id: %id).";
#endif
public string DbConnectionString { get; set; } = "server=127.0.0.1;uid=root;pwd=lighthouse;database=lighthouse";
public string ExternalUrl { get; set; } = "http://localhost:10060";