🐛 Bug fixes

This commit is contained in:
LittleSheep 2025-04-25 23:13:15 +08:00
parent c8e9f73746
commit 38b7e8c1a1
2 changed files with 23 additions and 1 deletions

View File

@ -16,7 +16,12 @@ public class AccountController(AppDatabase db, FileService fs, IMemoryCache memC
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<ActionResult<Account?>> GetByName(string name)
{
var account = await db.Accounts.Where(a => a.Name == name).FirstOrDefaultAsync();
var account = await db.Accounts
.Include(e => e.Profile)
.Include(e => e.Profile.Picture)
.Include(e => e.Profile.Background)
.Where(a => a.Name == name)
.FirstOrDefaultAsync();
return account is null ? new NotFoundResult() : account;
}

View File

@ -77,6 +77,23 @@ public class AuthController(
: challenge.Account.AuthFactors.ToList();
}
[HttpPost("challenge/{id}/factors/{factorId:long}")]
public async Task<ActionResult> RequestFactorCode([FromRoute] Guid id, [FromRoute] long factorId)
{
var challenge = await db.AuthChallenges
.Include(e => e.Account)
.Where(e => e.Id == id).FirstOrDefaultAsync();
if (challenge is null) return NotFound("Auth challenge was not found.");
var factor = await db.AccountAuthFactors
.Where(e => e.Id == factorId)
.Where(e => e.Account == challenge.Account).FirstOrDefaultAsync();
if (factor is null) return NotFound("Auth factor was not found.");
// TODO do the logic here
return Ok();
}
public class PerformChallengeRequest
{
[Required] public long FactorId { get; set; }