mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-05-18 23:42:28 +00:00
* Initial work for verifying login ticket signatures * Add candidate psn public key * Add candidate psn public key and fix nuget packages * Finalize npticket changes * Add support for ticket version 3.0 * Rework login system to link platform accounts instead of using ip addresses * Make linked accounts green instead of blue * Fix api building * Fix unit tests * Actually fix unit tests * Set unit test user's linked platform * Why was this the wrong default value? * Fix username change code * Make TicketHash hash the entire ticket instead of just the serial * Send password setup email when user sets their email for the first time * Changes from self review
54 lines
No EOL
1.9 KiB
C#
54 lines
No EOL
1.9 KiB
C#
#nullable enable
|
|
using JetBrains.Annotations;
|
|
using LBPUnion.ProjectLighthouse.Helpers;
|
|
using LBPUnion.ProjectLighthouse.Levels;
|
|
using LBPUnion.ProjectLighthouse.PlayerData.Profiles;
|
|
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages;
|
|
|
|
public class LandingPage : BaseLayout
|
|
{
|
|
public LandingPage(Database database) : base(database)
|
|
{}
|
|
|
|
public int PendingAuthAttempts;
|
|
public List<User> PlayersOnline = new();
|
|
|
|
public List<Slot>? LatestTeamPicks;
|
|
public List<Slot>? NewestLevels;
|
|
|
|
[UsedImplicitly]
|
|
public async Task<IActionResult> OnGet()
|
|
{
|
|
User? user = this.Database.UserFromWebRequest(this.Request);
|
|
if (user != null && user.PasswordResetRequired) return this.Redirect("~/passwordResetRequired");
|
|
|
|
if (user != null)
|
|
this.PendingAuthAttempts = await this.Database.PlatformLinkAttempts
|
|
.CountAsync(l => l.UserId == user.UserId);
|
|
|
|
List<int> userIds = await this.Database.LastContacts.Where(l => TimeHelper.Timestamp - l.Timestamp < 300).Select(l => l.UserId).ToListAsync();
|
|
|
|
this.PlayersOnline = await this.Database.Users.Where(u => userIds.Contains(u.UserId)).ToListAsync();
|
|
|
|
const int maxShownLevels = 5;
|
|
|
|
this.LatestTeamPicks = await this.Database.Slots.Where(s => s.Type == SlotType.User && !s.SubLevel)
|
|
.Where(s => s.TeamPick)
|
|
.OrderByDescending(s => s.FirstUploaded)
|
|
.Take(maxShownLevels)
|
|
.Include(s => s.Creator)
|
|
.ToListAsync();
|
|
|
|
this.NewestLevels = await this.Database.Slots.Where(s => s.Type == SlotType.User && !s.SubLevel)
|
|
.OrderByDescending(s => s.FirstUploaded)
|
|
.Take(maxShownLevels)
|
|
.Include(s => s.Creator)
|
|
.ToListAsync();
|
|
|
|
return this.Page();
|
|
}
|
|
} |