Skip to content

Commit

Permalink
fix: don't show error view when cancelling oauth
Browse files Browse the repository at this point in the history
This is an intentional action from the user and not an error. Instead,
just return to the main screen.
  • Loading branch information
dphilipson committed Nov 13, 2024
1 parent aef02e1 commit 34185de
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions account-kit/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"@account-kit/core": "^4.3.1",
"@account-kit/infra": "^4.3.1",
"@account-kit/logging": "^4.3.1",
"@account-kit/signer": "^4.3.1",
"@tanstack/react-form": "^0.33.0",
"@tanstack/zod-form-adapter": "^0.33.0",
"@wagmi/connectors": "^5.1.15",
Expand Down
13 changes: 11 additions & 2 deletions account-kit/react/src/components/auth/card/loading/oauth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import { capitalize } from "../../../../utils.js";
import { useAuthContext } from "../../context.js";
import { useOAuthVerify } from "../../hooks/useOAuthVerify.js";
import { ConnectionError } from "../error/connection-error.js";
import { OauthCancelledError } from "@account-kit/signer";

export const CompletingOAuth = () => {
const { isConnected } = useSignerStatus();
const { setAuthStep, authStep } = useAuthContext("oauth_completing");
const { authenticate } = useOAuthVerify({ config: authStep.config });
const oauthWasCancelled = authStep.error instanceof OauthCancelledError;

useEffect(() => {
if (isConnected) {
Expand All @@ -18,10 +20,17 @@ export const CompletingOAuth = () => {
} else {
setAuthStep({ type: "complete" });
}
} else if (oauthWasCancelled) {
setAuthStep({ type: "initial" });
}
}, [authStep.createPasskeyAfter, isConnected, setAuthStep]);
}, [
authStep.createPasskeyAfter,
isConnected,
oauthWasCancelled,
setAuthStep,
]);

if (authStep.error) {
if (authStep.error && !oauthWasCancelled) {
return (
<ConnectionError
connectionType="oauth"
Expand Down

0 comments on commit 34185de

Please sign in to comment.