refactor(api): use convenience methods
This commit is contained in:
@@ -34,20 +34,12 @@ internal static class Endpoint
|
|||||||
|
|
||||||
if (user is null)
|
if (user is null)
|
||||||
{
|
{
|
||||||
return Results.Problem(
|
return Results.Unauthorized();
|
||||||
statusCode: StatusCodes.Status401Unauthorized,
|
|
||||||
title: "Unauthorized",
|
|
||||||
detail: "You are not authorized to connect an institution. Please log in and try again."
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user.Institutions.Any())
|
if (user.Institutions.Any())
|
||||||
{
|
{
|
||||||
return Results.Problem(
|
return Results.Conflict();
|
||||||
statusCode: StatusCodes.Status409Conflict,
|
|
||||||
title: "Institution already connected",
|
|
||||||
detail: "The user has already connected an institution with the provided Plaid Institution Id."
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var (itemId, accessToken) = await plaidService.ExchangeTokenAsync(request.PublicToken);
|
var (itemId, accessToken) = await plaidService.ExchangeTokenAsync(request.PublicToken);
|
||||||
|
|||||||
Reference in New Issue
Block a user