mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-05-03 17:38:22 +00:00
Allow instance owners to provide custom name, Include server version in LbpEnvVer
This is the first step towards instance customization. Just a name for now ;)
This commit is contained in:
parent
238894c2be
commit
ee541dbfae
8 changed files with 25 additions and 14 deletions
|
@ -130,7 +130,7 @@ public class LoginController : ControllerBase
|
||||||
new LoginResult
|
new LoginResult
|
||||||
{
|
{
|
||||||
AuthTicket = "MM_AUTH=" + token.UserToken,
|
AuthTicket = "MM_AUTH=" + token.UserToken,
|
||||||
LbpEnvVer = ServerStatics.ServerName,
|
ServerBrand = VersionHelper.FullVersion,
|
||||||
}.Serialize()
|
}.Serialize()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
Layout = "Layouts/BaseLayout";
|
Layout = "Layouts/BaseLayout";
|
||||||
Model.ShowTitleInPage = false;
|
Model.ShowTitleInPage = false;
|
||||||
}
|
}
|
||||||
<h1>Welcome to <b>Project Lighthouse</b>!</h1>
|
<h1>Welcome to <b>@ServerConfiguration.Instance.Customization.ServerName</b>!</h1>
|
||||||
|
|
||||||
@if (Model.User != null)
|
@if (Model.User != null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,6 +2,7 @@ using System.Net;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using LBPUnion.ProjectLighthouse.Configuration;
|
using LBPUnion.ProjectLighthouse.Configuration;
|
||||||
|
using LBPUnion.ProjectLighthouse.Helpers;
|
||||||
using LBPUnion.ProjectLighthouse.PlayerData;
|
using LBPUnion.ProjectLighthouse.PlayerData;
|
||||||
using LBPUnion.ProjectLighthouse.Tests;
|
using LBPUnion.ProjectLighthouse.Tests;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
@ -25,7 +26,7 @@ public class AuthenticationTests : LighthouseServerTest
|
||||||
Assert.True(response.IsSuccessStatusCode);
|
Assert.True(response.IsSuccessStatusCode);
|
||||||
string responseContent = await response.Content.ReadAsStringAsync();
|
string responseContent = await response.Content.ReadAsStringAsync();
|
||||||
Assert.Contains("MM_AUTH=", responseContent);
|
Assert.Contains("MM_AUTH=", responseContent);
|
||||||
Assert.Contains(ServerStatics.ServerName, responseContent);
|
Assert.Contains(VersionHelper.FullVersion, responseContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
[DatabaseFact]
|
[DatabaseFact]
|
||||||
|
@ -35,10 +36,10 @@ public class AuthenticationTests : LighthouseServerTest
|
||||||
|
|
||||||
Assert.NotNull(loginResult);
|
Assert.NotNull(loginResult);
|
||||||
Assert.NotNull(loginResult.AuthTicket);
|
Assert.NotNull(loginResult.AuthTicket);
|
||||||
Assert.NotNull(loginResult.LbpEnvVer);
|
Assert.NotNull(loginResult.ServerBrand);
|
||||||
|
|
||||||
Assert.Contains("MM_AUTH=", loginResult.AuthTicket);
|
Assert.Contains("MM_AUTH=", loginResult.AuthTicket);
|
||||||
Assert.Equal(ServerStatics.ServerName, loginResult.LbpEnvVer);
|
Assert.Equal(VersionHelper.FullVersion, loginResult.ServerBrand);
|
||||||
}
|
}
|
||||||
|
|
||||||
[DatabaseFact]
|
[DatabaseFact]
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
namespace LBPUnion.ProjectLighthouse.Configuration.ConfigurationCategories;
|
||||||
|
|
||||||
|
public class CustomizationConfiguration
|
||||||
|
{
|
||||||
|
public string ServerName { get; set; } = "Project Lighthouse";
|
||||||
|
}
|
|
@ -163,6 +163,9 @@ public class ServerConfiguration
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
// TODO: Find a way to properly remove config options
|
||||||
|
// YamlDotNet hates that and it's fucking annoying.
|
||||||
|
// This seriously sucks. /rant
|
||||||
[Obsolete("Obsolete. Use the Website/GameApi/Api listen URLS instead.")]
|
[Obsolete("Obsolete. Use the Website/GameApi/Api listen URLS instead.")]
|
||||||
public string ListenUrl { get; set; } = "http://localhost:10060";
|
public string ListenUrl { get; set; } = "http://localhost:10060";
|
||||||
|
|
||||||
|
@ -193,5 +196,5 @@ public class ServerConfiguration
|
||||||
public MailConfiguration Mail { get; set; } = new();
|
public MailConfiguration Mail { get; set; } = new();
|
||||||
public UserGeneratedContentLimitConfiguration UserGeneratedContentLimits { get; set; } = new();
|
public UserGeneratedContentLimitConfiguration UserGeneratedContentLimits { get; set; } = new();
|
||||||
public WebsiteConfiguration WebsiteConfiguration { get; set; } = new();
|
public WebsiteConfiguration WebsiteConfiguration { get; set; } = new();
|
||||||
|
public CustomizationConfiguration Customization { get; set; } = new();
|
||||||
}
|
}
|
|
@ -8,8 +8,6 @@ namespace LBPUnion.ProjectLighthouse.Configuration;
|
||||||
|
|
||||||
public static class ServerStatics
|
public static class ServerStatics
|
||||||
{
|
{
|
||||||
public const string ServerName = "ProjectLighthouse";
|
|
||||||
|
|
||||||
public const int PageSize = 20;
|
public const int PageSize = 20;
|
||||||
|
|
||||||
public static bool DbConnected {
|
public static bool DbConnected {
|
||||||
|
|
|
@ -31,8 +31,8 @@ public static class VersionHelper
|
||||||
{
|
{
|
||||||
Logger.Error
|
Logger.Error
|
||||||
(
|
(
|
||||||
"Project Lighthouse was built incorrectly. Please make sure git is available when building. " +
|
"Project Lighthouse was built incorrectly. Please make sure git is available when building.",
|
||||||
"Because of this, you will not be notified of updates.",
|
// "Because of this, you will not be notified of updates.",
|
||||||
LogArea.Startup
|
LogArea.Startup
|
||||||
);
|
);
|
||||||
CommitHash = "invalid";
|
CommitHash = "invalid";
|
||||||
|
@ -54,7 +54,7 @@ public static class VersionHelper
|
||||||
|
|
||||||
public static string CommitHash { get; set; }
|
public static string CommitHash { get; set; }
|
||||||
public static string Branch { get; set; }
|
public static string Branch { get; set; }
|
||||||
public static string FullVersion => $"{ServerStatics.ServerName} {Branch}@{CommitHash} {Build}";
|
public static string FullVersion => $"{ServerConfiguration.Instance.Customization.ServerName} {Branch}@{CommitHash} {Build}";
|
||||||
public static bool IsDirty => CommitHash.EndsWith("-dirty") || CommitsOutOfDate != 1 || CommitHash == "invalid" || Branch == "invalid";
|
public static bool IsDirty => CommitHash.EndsWith("-dirty") || CommitsOutOfDate != 1 || CommitHash == "invalid" || Branch == "invalid";
|
||||||
public static int CommitsOutOfDate { get; set; }
|
public static int CommitsOutOfDate { get; set; }
|
||||||
public static bool CanCheckForUpdates { get; set; }
|
public static bool CanCheckForUpdates { get; set; }
|
||||||
|
|
|
@ -15,9 +15,12 @@ public class LoginResult
|
||||||
public string AuthTicket { get; set; }
|
public string AuthTicket { get; set; }
|
||||||
|
|
||||||
[XmlElement("lbpEnvVer")]
|
[XmlElement("lbpEnvVer")]
|
||||||
public string LbpEnvVer { get; set; }
|
public string ServerBrand { get; set; }
|
||||||
|
|
||||||
public string Serialize()
|
public string Serialize()
|
||||||
=> LbpSerializer.Elements
|
=> LbpSerializer.Elements
|
||||||
(new KeyValuePair<string, object>("authTicket", this.AuthTicket), new KeyValuePair<string, object>("lbpEnvVer", this.LbpEnvVer));
|
(
|
||||||
|
new KeyValuePair<string, object>("authTicket", this.AuthTicket),
|
||||||
|
new KeyValuePair<string, object>("lbpEnvVer", this.ServerBrand)
|
||||||
|
);
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue