mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-31 01:08:41 +00:00
Show authentication attempts on landing page
This commit is contained in:
parent
ba91a9994f
commit
5b8d9cdb10
2 changed files with 17 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
|||
@page "/"
|
||||
@using LBPUnion.ProjectLighthouse.Types
|
||||
@using LBPUnion.ProjectLighthouse.Types.Settings
|
||||
@model LBPUnion.ProjectLighthouse.Pages.LandingPage
|
||||
|
||||
@{
|
||||
|
@ -11,6 +12,12 @@
|
|||
@if (Model.User != null)
|
||||
{
|
||||
<p>You are currently logged in as <b>@Model.User.Username</b>.</p>
|
||||
if (ServerSettings.Instance.UseExternalAuth && Model.AuthenticationAttemptsCount > 0)
|
||||
{
|
||||
<p>
|
||||
<b>You have @Model.AuthenticationAttemptsCount authentication attempts pending. Click <a href="/authentication">here</a> to view them.</b>
|
||||
</p>
|
||||
}
|
||||
}
|
||||
|
||||
@if (Model.PlayersOnlineCount == 1)
|
||||
|
@ -21,6 +28,7 @@
|
|||
<a href="/user/@user.UserId">@user.Username</a>
|
||||
}
|
||||
}
|
||||
|
||||
else if (Model.PlayersOnlineCount == 0)
|
||||
{
|
||||
<p>There are no users online. Why not hop on?</p>
|
||||
|
|
|
@ -16,6 +16,8 @@ namespace LBPUnion.ProjectLighthouse.Pages
|
|||
public List<User> PlayersOnline;
|
||||
|
||||
public int PlayersOnlineCount;
|
||||
|
||||
public int AuthenticationAttemptsCount;
|
||||
public LandingPage(Database database) : base(database)
|
||||
{}
|
||||
|
||||
|
@ -27,6 +29,13 @@ namespace LBPUnion.ProjectLighthouse.Pages
|
|||
|
||||
this.PlayersOnlineCount = await StatisticsHelper.RecentMatches();
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
this.AuthenticationAttemptsCount = await this.Database.AuthenticationAttempts.Include
|
||||
(a => a.GameToken)
|
||||
.CountAsync(a => a.GameToken.UserId == user.UserId);
|
||||
}
|
||||
|
||||
List<int> userIds = await this.Database.LastContacts.Where(l => TimestampHelper.Timestamp - l.Timestamp < 300).Select(l => l.UserId).ToListAsync();
|
||||
|
||||
this.PlayersOnline = await this.Database.Users.Where(u => userIds.Contains(u.UserId)).ToListAsync();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue