- Move login and refresh endpoints under a unified /auth route group
- Relocate institution connection logic from /accounts to /institutions
- Implement GET /institutions/{id}/available to fetch real-time Plaid
accounts
- Introduce HttpRequestBuilder utility to streamline integration testing
- Enhance PlaidService with GetAccountsAsync to support account fetching
- Clean up global usings and project structure for better domain
isolation
32 lines
884 B
C#
32 lines
884 B
C#
namespace FiscalOS.API.Http;
|
|
|
|
internal static class HttpContextExtensions
|
|
{
|
|
private const string RefreshTokenCookieName = "fiscalos_refresh_cookie";
|
|
|
|
public static Guid GetUserId(this HttpContext context)
|
|
{
|
|
var id = context.User.FindFirstValue(ClaimTypes.NameIdentifier) ?? string.Empty;
|
|
return Guid.TryParse(id, out var userId) ? userId : Guid.Empty;
|
|
}
|
|
|
|
public static void SetRefreshTokenCookie(this HttpContext context, RefreshToken token)
|
|
{
|
|
context.Response.Cookies.Append(
|
|
RefreshTokenCookieName,
|
|
token.Token,
|
|
new CookieOptions
|
|
{
|
|
HttpOnly = true,
|
|
Expires = token.ExpiresAt,
|
|
SameSite = SameSiteMode.Strict,
|
|
Secure = true
|
|
}
|
|
);
|
|
}
|
|
|
|
public static string GetRefreshTokenFromCookie(this HttpContext context)
|
|
{
|
|
return context.Request.Cookies[RefreshTokenCookieName] ?? string.Empty;
|
|
}
|
|
} |