Radicade Public Code

This commit is contained in:
JogmansonReal
2026-10-16 23:33:13 -07:00
commit 55175acdf6
832 changed files with 363261 additions and 0 deletions
+55
View File
@@ -0,0 +1,55 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using RadicadeServer.DB;
using RadicadeServer.RecNet.Auth.Cached;
using RadicadeServer.RecNet.Enums.Players;
namespace RadicadeServer.Auth.Cached
{
[Route("auth/cachedlogin")]
public class CachedLoginAPI : Controller
{
RecDBContext db;
public CachedLoginAPI(RecDBContext context)
{
this.db = context;
}
[HttpGet("forplatformid/{platform}/{platformId}")]
public async Task<IActionResult> GetCachedLoginsForPlatformId(Platforms platform, string platformId)
{
if (platform == Platforms.Standalone) return Ok(new List<CachedLogin>());
var cached = await db.CachedLogins.AsNoTracking()
.Where(login => login.platformId == platformId && login.platform == platform)
.Where(login => db.Players.Any(player => player.AccountId == login.accountId))
.Where(login => db.Profiles.Any(profile => profile.accountId == login.accountId))
.Where(login => db.Presences.Any(presence => presence.playerId == login.accountId))
.OrderByDescending(login => login.lastLoginTime)
.ToListAsync();
return Ok(cached);
}
[HttpPost("forplatformids")]
public async Task<List<CachedLogin>> GetCachedLoginsForPlatformIds([FromForm] string[] id)
{
if (id == null || id.Length <= 0) return [];
var requestedIds = id.Where(platformId => !string.IsNullOrWhiteSpace(platformId))
.Distinct(StringComparer.Ordinal).ToArray();
var cachedLogins = new List<CachedLogin>();
foreach (var platformId in requestedIds)
{
var cached = await db.CachedLogins.AsNoTracking()
.Where(login => login.platformId == platformId && login.platform != Platforms.Standalone)
.Where(login => db.Players.Any(player => player.AccountId == login.accountId))
.Where(login => db.Profiles.Any(profile => profile.accountId == login.accountId))
.Where(login => db.Presences.Any(presence => presence.playerId == login.accountId))
.OrderByDescending(login => login.lastLoginTime)
.FirstOrDefaultAsync();
if (cached != null) cachedLogins.Add(cached);
}
return cachedLogins;
}
}
}