fix session
This commit is contained in:
@@ -55,10 +55,10 @@ public class AuthApiController : ControllerBase
|
|||||||
var session = new Session
|
var session = new Session
|
||||||
{
|
{
|
||||||
AccountId = account.Id,
|
AccountId = account.Id,
|
||||||
TokenHash = tokenHash,
|
TokenHash = tokenHash.ToString(),
|
||||||
CreatedAt = DateTime.UtcNow,
|
CreatedAt = DateTime.UtcNow,
|
||||||
ExpiresAt = DateTime.UtcNow.AddDays(7), // 7 day expiry for API tokens
|
ExpiresAt = DateTime.UtcNow.AddDays(7), // 7 day expiry for API tokens
|
||||||
IpAddress = HttpContext.Connection.RemoteIpAddress?.ToString(),
|
CreatedIp = HttpContext.Connection.RemoteIpAddress?.ToString(),
|
||||||
UserAgent = Request.Headers.UserAgent.ToString()
|
UserAgent = Request.Headers.UserAgent.ToString()
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ public class AuthApiController : ControllerBase
|
|||||||
|
|
||||||
var tokenHash = HashToken(token);
|
var tokenHash = HashToken(token);
|
||||||
var session = await _db.Sessions
|
var session = await _db.Sessions
|
||||||
.FirstOrDefaultAsync(s => s.TokenHash == tokenHash && s.RevokedAt == null);
|
.FirstOrDefaultAsync(s => s.TokenHash == tokenHash.ToString() && s.RevokedAt == null);
|
||||||
|
|
||||||
if (session == null)
|
if (session == null)
|
||||||
return NotFound(new { error = "Session not found" });
|
return NotFound(new { error = "Session not found" });
|
||||||
|
|||||||
Reference in New Issue
Block a user