Skip to content

Commit

Permalink
Merge pull request #96 from near/increase-catch-scope
Browse files Browse the repository at this point in the history
fix: make catch not miss parent scope errors
  • Loading branch information
esaminu authored Oct 23, 2023
2 parents 8648f7f + 5b1949d commit 23b534f
Showing 1 changed file with 34 additions and 36 deletions.
70 changes: 34 additions & 36 deletions src/components/AuthCallback/AuthCallback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -249,44 +249,42 @@ function AuthCallbackPage() {
networkId
});

try {
await window.fastAuthController.setKey(keypair);
await window.fastAuthController.claimOidcToken(user.accessToken);
(window as any).firestoreController = new FirestoreController();
window.firestoreController.updateUser({
userUid: user.uid,
oidcToken: user.accessToken,
});
await window.fastAuthController.setKey(keypair);
await window.fastAuthController.claimOidcToken(user.accessToken);
(window as any).firestoreController = new FirestoreController();
window.firestoreController.updateUser({
userUid: user.uid,
oidcToken: user.accessToken,
});

const callback = isRecovery ? onSignIn : onCreateAccount;
await callback({
keypair,
accessToken: user.accessToken,
accountId,
publicKeyFak,
public_key_lak,
contract_id,
methodNames,
success_url,
setStatusMessage,
email,
navigate,
searchParams,
gateway: success_url,
});
} catch (e) {
console.log('error:', e);
const { message } = e;
const parsedUrl = new URL(failure_url || success_url || window.location.origin);
parsedUrl.searchParams.set('code', e.code);
parsedUrl.searchParams.set('reason', message);
window.location.replace(parsedUrl.href);
openToast({
type: 'ERROR',
title: message,
});
}
const callback = isRecovery ? onSignIn : onCreateAccount;
await callback({
keypair,
accessToken: user.accessToken,
accountId,
publicKeyFak,
public_key_lak,
contract_id,
methodNames,
success_url,
setStatusMessage,
email,
navigate,
searchParams,
gateway: success_url,
});
}
}).catch((e) => {
console.log('error:', e);
const { message } = e;
const parsedUrl = new URL(failure_url || success_url || window.location.origin);
parsedUrl.searchParams.set('code', e.code);
parsedUrl.searchParams.set('reason', message);
window.location.replace(parsedUrl.href);
openToast({
type: 'ERROR',
title: message,
});
});
} else {
navigate('/signup');
Expand Down

0 comments on commit 23b534f

Please sign in to comment.