mirror of
https://github.com/neynarxyz/create-farcaster-mini-app.git
synced 2025-11-16 08:08:56 -05:00
If within farcaster redirect skip grant access screen
This commit is contained in:
parent
485c190695
commit
822db9101f
@ -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,10 +192,15 @@ export function AuthDialog({
|
|||||||
<button
|
<button
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
window.open(
|
window.open(
|
||||||
content.qrUrl.replace(
|
content.qrUrl
|
||||||
'https://farcaster.xyz/',
|
.replace(
|
||||||
'farcaster://'
|
'https://farcaster.xyz/',
|
||||||
),
|
'https://client.farcaster.xyz/deeplinks/'
|
||||||
|
)
|
||||||
|
.replace(
|
||||||
|
'https://client.farcaster.xyz/deeplinks/',
|
||||||
|
'farcaster://'
|
||||||
|
),
|
||||||
'_blank'
|
'_blank'
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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
|
||||||
setDialogStep('access'); // Switch to access step to show QR
|
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
|
||||||
|
}
|
||||||
|
|
||||||
// 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);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user