chore: move clearCookie to finally

This commit is contained in:
bo0tzz
2026-04-18 15:25:22 +02:00
parent d50ea005a1
commit f4e016edb5
+3 -4
View File
@@ -75,8 +75,6 @@ export class OAuthController {
): Promise<LoginResponseDto> { ): Promise<LoginResponseDto> {
try { try {
const body = await this.service.callback(dto, request.headers, loginDetails); const body = await this.service.callback(dto, request.headers, loginDetails);
res.clearCookie(ImmichCookie.OAuthState);
res.clearCookie(ImmichCookie.OAuthCodeVerifier);
return respondWithCookie(res, body, { return respondWithCookie(res, body, {
isSecure: loginDetails.isSecure, isSecure: loginDetails.isSecure,
values: [ values: [
@@ -87,14 +85,15 @@ export class OAuthController {
}); });
} catch (error) { } catch (error) {
if (error instanceof OAuthLinkRequiredException) { if (error instanceof OAuthLinkRequiredException) {
res.clearCookie(ImmichCookie.OAuthState);
res.clearCookie(ImmichCookie.OAuthCodeVerifier);
respondWithCookie(res, null, { respondWithCookie(res, null, {
isSecure: loginDetails.isSecure, isSecure: loginDetails.isSecure,
values: [{ key: ImmichCookie.OAuthLinkToken, value: error.oauthLinkToken }], values: [{ key: ImmichCookie.OAuthLinkToken, value: error.oauthLinkToken }],
}); });
} }
throw error; throw error;
} finally {
res.clearCookie(ImmichCookie.OAuthState);
res.clearCookie(ImmichCookie.OAuthCodeVerifier);
} }
} }