diff --git a/public/client-metadata.json b/public/client-metadata.json index 74e4bba..7232f10 100644 --- a/public/client-metadata.json +++ b/public/client-metadata.json @@ -1,9 +1,9 @@ { - "client_id": "https://cred.blue/client-metadata.json", + "client_id": "https://testing.cred.blue/client-metadata.json", "client_name": "cred.blue", - "client_uri": "https://cred.blue", + "client_uri": "https://testing.cred.blue", "redirect_uris": [ - "https://cred.blue/login/callback" + "https://testing.cred.blue/login/callback" ], "scope": "atproto transition:generic", "grant_types": [ diff --git a/src/components/Login/LoginCallback.js b/src/components/Login/LoginCallback.js index 367b860..15768a3 100644 --- a/src/components/Login/LoginCallback.js +++ b/src/components/Login/LoginCallback.js @@ -1,5 +1,5 @@ import React, { useEffect, useState } from 'react'; -import { useNavigate } from 'react-router-dom'; +import { useNavigate, useLocation } from 'react-router-dom'; import { useAuth } from '../../contexts/AuthContext'; import './LoginCallback.css'; // Optional: Add styles if needed @@ -7,6 +7,7 @@ const LoginCallback = () => { // Get loading and authentication status from AuthContext const { loading, isAuthenticated, error: authError } = useAuth(); const navigate = useNavigate(); + const location = useLocation(); const [localError, setLocalError] = useState(null); useEffect(() => { @@ -18,8 +19,12 @@ const LoginCallback = () => { // Once loading is complete, check the authentication status if (isAuthenticated) { console.log('(LoginCallback) Authentication successful, redirecting...'); - // TODO: Implement state parsing for returnUrl if needed - const returnUrl = '/verifier'; // Changed redirect target + + // Parse returnUrl from query parameters + const searchParams = new URLSearchParams(location.search); + const returnUrl = searchParams.get('returnUrl') || '/verifier'; + + console.log(`(LoginCallback) Redirecting to: ${returnUrl}`); navigate(returnUrl, { replace: true }); // Use replace to avoid callback in history } else { // If not authenticated after loading, something went wrong @@ -27,7 +32,7 @@ const LoginCallback = () => { setLocalError(authError || 'Authentication failed. Please try logging in again.'); } - }, [loading, isAuthenticated, navigate, authError]); // Depend on loading and auth state + }, [loading, isAuthenticated, navigate, authError, location]); // Added location dependency // Display loading message if (loading) { diff --git a/src/contexts/AuthContext.js b/src/contexts/AuthContext.js index 7c213ad..45628dd 100644 --- a/src/contexts/AuthContext.js +++ b/src/contexts/AuthContext.js @@ -7,11 +7,11 @@ export const AuthContext = createContext(null); // Client metadata for Bluesky OAuth const clientMetadata = { - client_id: `https://cred.blue/client-metadata.json`, + client_id: `https://testing.cred.blue/client-metadata.json`, client_name: "cred.blue", - client_uri: `https://cred.blue`, - redirect_uris: [`https://cred.blue/login/callback`], - logo_uri: `https://cred.blue/favicon.ico`, + client_uri: `https://testing.cred.blue`, + redirect_uris: [`https://testing.cred.blue/login/callback`], + logo_uri: `https://testing.cred.blue/favicon.ico`, scope: "atproto transition:generic", grant_types: ["authorization_code", "refresh_token"], response_types: ["code"],