If within farcaster redirect skip grant access screen

This commit is contained in:
Shreyaschorge 2025-07-08 19:16:39 +05:30
parent 485c190695
commit 822db9101f
No known key found for this signature in database
2 changed files with 18 additions and 9 deletions

View File

@ -149,9 +149,6 @@ export function AuthDialog({
<div className='text-red-600 dark:text-red-400 mb-4'> <div className='text-red-600 dark:text-red-400 mb-4'>
{error?.message || 'Unknown error, please try again.'} {error?.message || 'Unknown error, please try again.'}
</div> </div>
<button onClick={onClose} className='btn btn-primary'>
Try Again
</button>
</div> </div>
) : ( ) : (
<div className='text-center'> <div className='text-center'>
@ -195,8 +192,13 @@ export function AuthDialog({
<button <button
onClick={() => onClick={() =>
window.open( window.open(
content.qrUrl.replace( content.qrUrl
.replace(
'https://farcaster.xyz/', 'https://farcaster.xyz/',
'https://client.farcaster.xyz/deeplinks/'
)
.replace(
'https://client.farcaster.xyz/deeplinks/',
'farcaster://' 'farcaster://'
), ),
'_blank' '_blank'

View File

@ -9,8 +9,10 @@ import { isMobile } from '~/lib/devices';
import { ProfileButton } from '~/components/ui/NeynarAuthButton/ProfileButton'; import { ProfileButton } from '~/components/ui/NeynarAuthButton/ProfileButton';
import { AuthDialog } from '~/components/ui/NeynarAuthButton/AuthDialog'; import { AuthDialog } from '~/components/ui/NeynarAuthButton/AuthDialog';
import { getItem, removeItem, setItem } from '~/lib/localStorage'; import { getItem, removeItem, setItem } from '~/lib/localStorage';
import { useMiniApp } from '@neynar/react';
const STORAGE_KEY = 'neynar_authenticated_user'; const STORAGE_KEY = 'neynar_authenticated_user';
const FARCASTER_FID = 9152;
interface StoredAuthState { interface StoredAuthState {
isAuthenticated: boolean; isAuthenticated: boolean;
@ -34,7 +36,7 @@ export function NeynarAuthButton() {
const [nonce, setNonce] = useState<string | null>(null); const [nonce, setNonce] = useState<string | null>(null);
const [storedAuth, setStoredAuth] = useState<StoredAuthState | null>(null); const [storedAuth, setStoredAuth] = useState<StoredAuthState | null>(null);
const [signersLoading, setSignersLoading] = useState(false); const [signersLoading, setSignersLoading] = useState(false);
const { context } = useMiniApp();
// New state for unified dialog flow // New state for unified dialog flow
const [showDialog, setShowDialog] = useState(false); const [showDialog, setShowDialog] = useState(false);
const [dialogStep, setDialogStep] = useState<'signin' | 'access' | 'loading'>( const [dialogStep, setDialogStep] = useState<'signin' | 'access' | 'loading'>(
@ -297,7 +299,12 @@ export function NeynarAuthButton() {
if (signedKeyData.signer_approval_url) { if (signedKeyData.signer_approval_url) {
setSignerApprovalUrl(signedKeyData.signer_approval_url); setSignerApprovalUrl(signedKeyData.signer_approval_url);
setSignersLoading(false); // Stop loading, show QR code setSignersLoading(false); // Stop loading, show QR code
if (context?.client?.clientFid === FARCASTER_FID) {
setShowDialog(false);
window.open(signedKeyData.signer_approval_url, '_blank');
} else {
setDialogStep('access'); // Switch to access step to show QR setDialogStep('access'); // Switch to access step to show QR
}
// Step 4: Start polling for signer approval // Step 4: Start polling for signer approval
startPolling(newSigner.signer_uuid, data.message, data.signature); startPolling(newSigner.signer_uuid, data.message, data.signature);