From e7d81c5cdf33489269a41444e153b574e775b979 Mon Sep 17 00:00:00 2001 From: Erik Michelson Date: Wed, 9 Oct 2024 00:36:52 +0200 Subject: [PATCH] refactor(oidc): simplify callback statement Signed-off-by: Erik Michelson --- backend/src/identity/oidc/oidc.service.ts | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/backend/src/identity/oidc/oidc.service.ts b/backend/src/identity/oidc/oidc.service.ts index eb96d48ed..09b706f82 100644 --- a/backend/src/identity/oidc/oidc.service.ts +++ b/backend/src/identity/oidc/oidc.service.ts @@ -187,17 +187,14 @@ export class OidcService { const code = request.session.oidcLoginCode; const state = request.session.oidcLoginState; const isAutodiscovered = clientConfig.config.authorizeUrl === undefined; - const tokenSet = isAutodiscovered - ? await client.callback(clientConfig.redirectUri, params, { - // eslint-disable-next-line @typescript-eslint/naming-convention - code_verifier: code, - state, - }) - : await client.oauthCallback(clientConfig.redirectUri, params, { - // eslint-disable-next-line @typescript-eslint/naming-convention - code_verifier: code, - state, - }); + const callbackMethod = isAutodiscovered + ? client.callback.bind(this) + : client.oauthCallback.bind(this); + const tokenSet = await callbackMethod(clientConfig.redirectUri, params, { + // eslint-disable-next-line @typescript-eslint/naming-convention + code_verifier: code, + state, + }); request.session.oidcIdToken = tokenSet.id_token; const userInfoResponse = await client.userinfo(tokenSet);