41 lines
1.4 KiB
C#
41 lines
1.4 KiB
C#
using DeluxeBackend.Models;
|
|
using DeluxeBackend.Services;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using System.Numerics;
|
|
using static DeluxeBackend.Enums;
|
|
|
|
namespace DeluxeBackend.Controllers.Auth
|
|
{
|
|
[Route("Auth/cachedlogin")]
|
|
[ApiController]
|
|
public class CachedLoginController : ControllerBase
|
|
{
|
|
private readonly ILiteDbService db;
|
|
public CachedLoginController(ILiteDbService _db)
|
|
{
|
|
db = _db;
|
|
}
|
|
[HttpGet("forplatformid/{platform}/{platformId}")]
|
|
public async Task<IActionResult> ForPlatformId([FromRoute] PlatformType platform, [FromRoute] string platformId)
|
|
{
|
|
List<Dictionary<string, object>> logins = new List<Dictionary<string, object>>();
|
|
|
|
foreach (Cachedlogin item in db.Cachedlogins.Include(x => x.Account).Find(x => x.Platform == platform && x.PlatformId == platformId).OrderByDescending(x => x.LastLoginAt))
|
|
{
|
|
logins.Add(new Dictionary<string, object>
|
|
{
|
|
["platform"] = (int)item.Platform,
|
|
["platformId"] = item.PlatformId,
|
|
["accountId"] = item.Account.Id,
|
|
["lastLoginTime"] = item.LastLoginAt.ToString("O"),
|
|
["requirePassword"] = item.RequirePassword
|
|
});
|
|
}
|
|
|
|
|
|
return Ok(logins);
|
|
}
|
|
}
|
|
}
|