diff --git a/Security/Services/AuthService.cs b/Security/Services/AuthService.cs index 97592b7..25234f9 100644 --- a/Security/Services/AuthService.cs +++ b/Security/Services/AuthService.cs @@ -183,8 +183,18 @@ public class AuthService(ICacheService cache, IAccessToken accessTokenService, I public Task LoginOAuthAsync(CookieOptions cookieOptions, HttpContext context, User user, - CancellationToken cancellation = default) => - LoginAsync(cookieOptions, context, user, cancellation); + OAuthUser oAuthUser, + OAuthProvider provider, + CancellationToken cancellation = default) + { + if (user.OAuthProviders == null || !user.OAuthProviders.TryGetValue(provider, out var value)) + throw new SecurityException($"This provider '{Enum.GetName(provider)}' is not linked to the account."); + + if (value.Id != oAuthUser.Id) + throw new SecurityException("This account was not linked"); + + return LoginAsync(cookieOptions, context, user, cancellation); + } public async Task LoginAsync(CookieOptions cookieOptions, HttpContext context,