refactor(application): change GetOAuth2AuthorizationUrlQuery to look up account by Username instead of Id
This commit is contained in:
@@ -17,7 +17,7 @@ public record GetOAuth2AuthorizationUrlQuery : IRequest<string>
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// ID of the email account to authorize.
|
/// ID of the email account to authorize.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public required int AccountId { get; init; }
|
public required string Username { get; init; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The redirect URI registered with the OAuth2 provider.
|
/// The redirect URI registered with the OAuth2 provider.
|
||||||
@@ -32,8 +32,8 @@ public class GetOAuth2AuthorizationUrlQueryHandler(
|
|||||||
{
|
{
|
||||||
public async Task<string> Handle(GetOAuth2AuthorizationUrlQuery request, CancellationToken cancellationToken)
|
public async Task<string> Handle(GetOAuth2AuthorizationUrlQuery request, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var account = await Repo.GetByIdAsync(request.AccountId, cancellationToken)
|
var account = await Repo.FindFirstAsync(e => e.Username == request.Username, cancellationToken)
|
||||||
?? throw new NotFoundException($"No email account found with Id: {request.AccountId}.");
|
?? throw new NotFoundException($"No email account found with username: {request.Username}.");
|
||||||
|
|
||||||
if (account.OAuth2Provider == OAuth2Provider.None)
|
if (account.OAuth2Provider == OAuth2Provider.None)
|
||||||
throw new BadRequestException(
|
throw new BadRequestException(
|
||||||
|
|||||||
Reference in New Issue
Block a user