Refactor
This commit is contained in:
parent
b99b3d29d9
commit
6a95056731
1 changed files with 9 additions and 16 deletions
|
|
@ -89,33 +89,26 @@ export const oauthTransitions: Record<OAuthStep, StateTransition> = {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try DCR first, with static client as fallback
|
// Try DCR first, with static client as fallback
|
||||||
|
let fullInformation;
|
||||||
try {
|
try {
|
||||||
const fullInformation = await registerClient(context.serverUrl, {
|
fullInformation = await registerClient(context.serverUrl, {
|
||||||
metadata,
|
metadata,
|
||||||
clientMetadata,
|
clientMetadata,
|
||||||
});
|
});
|
||||||
|
|
||||||
context.provider.saveClientInformation(fullInformation);
|
context.provider.saveClientInformation(fullInformation);
|
||||||
context.updateState({
|
|
||||||
oauthClientInfo: fullInformation,
|
|
||||||
oauthStep: "authorization_redirect",
|
|
||||||
});
|
|
||||||
console.log({ fullInformation });
|
|
||||||
return;
|
|
||||||
} catch (dcrError) {
|
} catch (dcrError) {
|
||||||
console.error(dcrError);
|
|
||||||
|
|
||||||
// DCR failed, fallback to preregistered client
|
// DCR failed, fallback to preregistered client
|
||||||
const existingClientInfo = await context.provider.clientInformation();
|
fullInformation = await context.provider.clientInformation();
|
||||||
if (!existingClientInfo) {
|
if (!fullInformation) {
|
||||||
console.error("Neither dynamic client registration or preregistered client information was found");
|
console.error("Neither dynamic client registration or preregistered client information was found");
|
||||||
throw dcrError;
|
throw dcrError;
|
||||||
}
|
}
|
||||||
context.updateState({
|
|
||||||
oauthClientInfo: existingClientInfo,
|
|
||||||
oauthStep: "authorization_redirect",
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
context.updateState({
|
||||||
|
oauthClientInfo: fullInformation,
|
||||||
|
oauthStep: "authorization_redirect",
|
||||||
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue