Skip to content

Commit 322a014

Browse files
gregfromstlclaude
andcommitted
[Thirdweb] Fix: Automatically trigger login for connected wallets when auth is required
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 557a29a commit 322a014

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

.changeset/every-sides-invent.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
Automatically trigger SIWE sign in when a wallet is connected

packages/thirdweb/src/react/web/ui/ConnectWallet/ConnectButton.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,24 @@ function ConnectButtonInner(
410410
}
411411
}, [activeAccount]);
412412

413+
// if the wallet is connected and auth is required, trigger a login attempt automatically
414+
useEffect(() => {
415+
if (
416+
activeAccount &&
417+
siweAuth.requiresAuth &&
418+
!siweAuth.isLoggedIn &&
419+
!siweAuth.isLoggingIn
420+
) {
421+
siweAuth.doLogin();
422+
}
423+
}, [
424+
activeAccount,
425+
siweAuth.requiresAuth,
426+
siweAuth.doLogin,
427+
siweAuth.isLoggedIn,
428+
siweAuth.isLoggingIn,
429+
]);
430+
413431
const theme = props.theme || "dark";
414432
const connectionStatus = useActiveWalletConnectionStatus();
415433
const locale = props.connectLocale;

0 commit comments

Comments
 (0)