Separate EULA and announce endpoints by purpose

Also fixes LBP3 login not showing anything
This commit is contained in:
jvyden 2021-10-31 18:11:08 -04:00
parent 6a787bd1dd
commit 79be3e175b
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278
2 changed files with 12 additions and 5 deletions

View file

@ -28,16 +28,20 @@ namespace LBPUnion.ProjectLighthouse.Controllers
? this.StatusCode(403, "")
: this.Ok
(
$"You are now logged in as user {user.Username} (id {user.UserId}).\n" +
// ReSharper disable once UnreachableCode
(EulaHelper.ShowPrivateInstanceNotice ? "\n" + EulaHelper.PrivateInstanceNotice : "") +
EulaHelper.PrivateInstanceNoticeOrBlank +
"\n" +
$"{EulaHelper.License}\n"
);
}
[HttpGet("announce")]
public IActionResult Announce() => this.Ok("");
public async Task<IActionResult> Announce()
{
User user = await this.database.UserFromRequest(this.Request);
if (user == null) return this.StatusCode(403, "");
return this.Ok($"You are now logged in as user {user.Username} (id {user.UserId}).\n\n" + EulaHelper.PrivateInstanceNoticeOrBlank);
}
[HttpGet("notification")]
public IActionResult Notification() => this.Ok();

View file

@ -19,6 +19,9 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.";
public const string PrivateInstanceNotice = @"This server is a private testing instance.
Please do not make anything public for now, and keep in mind security isn't as tight as a full release would.";
public const bool ShowPrivateInstanceNotice = false;
// ReSharper disable once UnreachableCode
public const string PrivateInstanceNoticeOrBlank = ShowPrivateInstanceNotice ? PrivateInstanceNotice : "";
public const bool ShowPrivateInstanceNotice = true;
}
}