Skip to content

Commit

Permalink
Some code cleanup
Browse files Browse the repository at this point in the history
- We can use Ok<AccessTokenResponse> since the type is public now
  • Loading branch information
davidfowl committed Nov 23, 2024
1 parent fb0032e commit 2d0d82d
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions Todo.Api/Users/UsersApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static RouteGroupBuilder MapUsers(this IEndpointRouteBuilder routes)

// The MapIdentityApi<T> doesn't expose an external login endpoint so we write this custom endpoint that follows
// a similar pattern
group.MapPost("/token/{provider}", async Task<Results<SignInHttpResult, ValidationProblem>> (string provider, ExternalUserInfo userInfo, UserManager<TodoUser> userManager, SignInManager<TodoUser> signInManager) =>
group.MapPost("/token/{provider}", async Task<Results<Ok<AccessTokenResponse>, SignInHttpResult, ValidationProblem>> (string provider, ExternalUserInfo userInfo, UserManager<TodoUser> userManager, SignInManager<TodoUser> signInManager) =>
{
var user = await userManager.FindByLoginAsync(provider, userInfo.ProviderKey);

Expand All @@ -44,10 +44,7 @@ public static RouteGroupBuilder MapUsers(this IEndpointRouteBuilder routes)
}

return TypedResults.ValidationProblem(result.Errors.ToDictionary(e => e.Code, e => new[] { e.Description }));
})
// Add the open API response for 200 since AccessTokenResponse
// is internal and we don't want to duplicate it.
.Produces<AccessTokenResponse>();
});

return group;
}
Expand Down

0 comments on commit 2d0d82d

Please sign in to comment.