Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Update mobile unlock endpoints (#1347)
Leendert de Borst9017d0b64249
diff --git a/apps/server/AliasVault.Api/Controllers/AuthController.cs b/apps/server/AliasVault.Api/Controllers/AuthController.csindex 594fcf493..bea8091d9 100644--- a/apps/server/AliasVault.Api/Controllers/AuthController.cs+++ b/apps/server/AliasVault.Api/Controllers/AuthController.cs@@ -577,7 +577,7 @@ public class AuthController(IAliasServerDbContextFactory dbContextFactory, UserMvar unlockRequest = await context.MobileUnlockRequests.FirstOrDefaultAsync(r => r.Id == requestId);// Check if request exists and hasn't expired- if (unlockRequest == null || unlockRequest.ExpiresAt < timeProvider.UtcNow)+ if (unlockRequest == null || unlockRequest.CreatedAt.AddMinutes(2) < timeProvider.UtcNow){// Clean up expired request if it existsif (unlockRequest != null)@@ -654,6 +654,29 @@ public class AuthController(IAliasServerDbContextFactory dbContextFactory, UserMreturn Ok(response);}+ /// <summary>+ /// Gets the public key for a mobile unlock request (for mobile app to encrypt).+ /// </summary>+ /// <param name="requestId">The unique identifier for the unlock request.</param>+ /// <returns>IActionResult.</returns>+ [HttpGet("mobile-unlock/request/{requestId}")]+ [Authorize]+ public async Task<IActionResult> GetMobileUnlockRequest(string requestId)+ {+ await using var context = await dbContextFactory.CreateDbContextAsync();++ var unlockRequest = await context.MobileUnlockRequests.FirstOrDefaultAsync(r => r.Id == requestId);++ // Check if request exists and hasn't expired+ if (unlockRequest == null || unlockRequest.CreatedAt.AddMinutes(2) < timeProvider.UtcNow)+ {+ return NotFound(ApiErrorCodeHelper.CreateErrorResponse(ApiErrorCode.MOBILE_UNLOCK_REQUEST_NOT_FOUND, 404));+ }++ // Return only the public key+ return Ok(new { clientPublicKey = unlockRequest.ClientPublicKey });+ }+/// <summary>/// Submits a mobile unlock response from the mobile app./// </summary>@@ -681,7 +704,7 @@ public class AuthController(IAliasServerDbContextFactory dbContextFactory, UserMvar unlockRequest = await context.MobileUnlockRequests.FirstOrDefaultAsync(r => r.Id == model.RequestId);// Check if request exists and hasn't expired- if (unlockRequest == null || unlockRequest.ExpiresAt < timeProvider.UtcNow)+ if (unlockRequest == null || unlockRequest.CreatedAt.AddMinutes(2) < timeProvider.UtcNow){// Clean up expired request if it existsif (unlockRequest != null)