mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-05-04 09:58:22 +00:00
39 lines
No EOL
1.4 KiB
C#
39 lines
No EOL
1.4 KiB
C#
#nullable enable
|
|
using JetBrains.Annotations;
|
|
using LBPUnion.ProjectLighthouse.Helpers;
|
|
using LBPUnion.ProjectLighthouse.Types;
|
|
using LBPUnion.ProjectLighthouse.Website.Pages.Layouts;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace LBPUnion.ProjectLighthouse.Website.Pages;
|
|
|
|
public class LandingPage : BaseLayout
|
|
{
|
|
|
|
public int AuthenticationAttemptsCount;
|
|
public List<User> PlayersOnline = new();
|
|
|
|
public int PlayersOnlineCount;
|
|
public LandingPage(Database database) : base(database)
|
|
{}
|
|
|
|
[UsedImplicitly]
|
|
public async Task<IActionResult> OnGet()
|
|
{
|
|
User? user = this.Database.UserFromWebRequest(this.Request);
|
|
if (user != null && user.PasswordResetRequired) return this.Redirect("~/passwordResetRequired");
|
|
|
|
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();
|
|
return this.Page();
|
|
}
|
|
} |