From c189a2d6efa8889f5141c54450ce658b983008d6 Mon Sep 17 00:00:00 2001 From: TekH Date: Mon, 17 Aug 2026 16:05:16 +0200 Subject: [PATCH] refactor(application): change GetOAuth2AuthorizationUrlQuery to look up account by Username instead of Id --- .../OAuth2/Queries/GetOAuth2AuthorizationUrlQuery.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/DigitalData.MessagingService.Application/OAuth2/Queries/GetOAuth2AuthorizationUrlQuery.cs b/src/core/DigitalData.MessagingService.Application/OAuth2/Queries/GetOAuth2AuthorizationUrlQuery.cs index c07d760..6dadbce 100644 --- a/src/core/DigitalData.MessagingService.Application/OAuth2/Queries/GetOAuth2AuthorizationUrlQuery.cs +++ b/src/core/DigitalData.MessagingService.Application/OAuth2/Queries/GetOAuth2AuthorizationUrlQuery.cs @@ -17,7 +17,7 @@ public record GetOAuth2AuthorizationUrlQuery : IRequest /// /// ID of the email account to authorize. /// - public required int AccountId { get; init; } + public required string Username { get; init; } /// /// The redirect URI registered with the OAuth2 provider. @@ -32,8 +32,8 @@ public class GetOAuth2AuthorizationUrlQueryHandler( { public async Task Handle(GetOAuth2AuthorizationUrlQuery request, CancellationToken cancellationToken) { - var account = await Repo.GetByIdAsync(request.AccountId, cancellationToken) - ?? throw new NotFoundException($"No email account found with Id: {request.AccountId}."); + var account = await Repo.FindFirstAsync(e => e.Username == request.Username, cancellationToken) + ?? throw new NotFoundException($"No email account found with username: {request.Username}."); if (account.OAuth2Provider == OAuth2Provider.None) throw new BadRequestException(