Skip to content

Commit ca67cd4

Browse files
committed
account for redirect
1 parent c57fa34 commit ca67cd4

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/App.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,17 @@ const AppContent: React.FC = () => {
113113
}
114114

115115
// If user is logged in and trying to access auth page, redirect to account
116+
// UNLESS there's a callback/redirect_url parameter (CLI auth flow)
116117
if (user && currentPage === 'auth') {
117-
window.location.hash = 'account';
118-
return null;
118+
// Parse URL parameters from the hash (e.g., #auth?callback=...)
119+
const hashParts = window.location.hash.split('?');
120+
const urlParams = new URLSearchParams(hashParts[1] || '');
121+
const hasCallback = urlParams.get('callback') || urlParams.get('redirect_url');
122+
123+
if (!hasCallback) {
124+
window.location.hash = 'account';
125+
return null;
126+
}
119127
}
120128

121129
// If user is not logged in and trying to access account page, redirect to welcome

src/pages/Auth/Auth.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ const Auth: React.FC = () => {
2727
const [isRedirecting, setIsRedirecting] = useState(false);
2828

2929
// Get redirect URL from URL params (for CLI integration)
30-
const urlParams = new URLSearchParams(window.location.search);
31-
const redirectUrl = urlParams.get('redirect_url');
30+
// Parse URL parameters from the hash (e.g., #auth?callback=...)
31+
const hashParts = window.location.hash.split('?');
32+
const urlParams = new URLSearchParams(hashParts[1] || '');
33+
const redirectUrl = urlParams.get('redirect_url') || urlParams.get('callback');
3234

3335
const generateTokenAndRedirect = async () => {
3436
if (!redirectUrl || !user) return;

0 commit comments

Comments
 (0)