0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

refactor: reorder code

This commit is contained in:
Darcy Ye 2024-03-25 14:00:05 +08:00
parent 5ea8c49c5d
commit 55e04cc683
No known key found for this signature in database
GPG key ID: B46F4C07EDEFC610

View file

@ -217,12 +217,6 @@ export default function initOidc(
try {
const isTokenClientCredentials = token instanceof ctx.oidc.provider.ClientCredentials;
const pickedFields = isTokenClientCredentials
? ctx.oidc.provider.ClientCredentials.IN_PAYLOAD
: ctx.oidc.provider.AccessToken.IN_PAYLOAD;
const readOnlyToken = Object.fromEntries(
pickedFields.map((field) => [field, Reflect.get(token, field)])
);
const { script, envVars } =
(await trySafe(
@ -237,6 +231,13 @@ export default function initOidc(
return;
}
const pickedFields = isTokenClientCredentials
? ctx.oidc.provider.ClientCredentials.IN_PAYLOAD
: ctx.oidc.provider.AccessToken.IN_PAYLOAD;
const readOnlyToken = Object.fromEntries(
pickedFields.map((field) => [field, Reflect.get(token, field)])
);
const client = await cloudConnection.getClient();
// We pass context to the cloud API only when it is a user's access token.