cuddly-zebra-90373
08/03/2023, 2:02 PMfunction launchDescope(flowId){
const sdk = Descope({ projectId: projectId, autoRefresh: true });
const wcElement = document.getElementsByTagName('descope-wc')[0];
const onSuccess = (e) => {
// [... send tokens to backend, etc ...]
};
const onError = (err) => console.log("#### Descope error", err);
wcElement.addEventListener('success', onSuccess);
wcElement.addEventListener('error', onError);
}
Is there a way to detect if the user is already logged in so that I can render a full page overlay when the flow shows? The docs suggest:
const descopeSdk = descopeSdk({projectId: '__ProjectID__'});
const sessionToken = descopeSdk.getSessionToken();
if(isJwtExpired(sessionToken)) {
console.log('Session token has expired.');
} else {
console.log('Session token is valid.');
}
but getSessionToken() was removed from the WebJS SDK a while ago.
Is there an official approach for this? Looking at the SDK, nothing leaps out as a way to get this infogreat-diamond-35515
08/03/2023, 2:06 PMpersistTokens
option (see in pacakge readme)
const descopeSdk = descopeSdk({projectId: '__ProjectID__', persistTokens: true });
let me know if that works!
We will make sure to update the docs accordinglycuddly-zebra-90373
08/03/2023, 2:09 PMgreat-diamond-35515
08/03/2023, 2:11 PMcuddly-zebra-90373
08/03/2023, 2:12 PM