···
1
1
{
2
2
-
"client_id": "https://cred.blue/client-metadata.json",
2
2
+
"client_id": "https://testing.cred.blue/client-metadata.json",
3
3
"client_name": "cred.blue",
4
4
-
"client_uri": "https://cred.blue",
4
4
+
"client_uri": "https://testing.cred.blue",
5
5
"redirect_uris": [
6
6
-
"https://cred.blue/login/callback"
6
6
+
"https://testing.cred.blue/login/callback"
7
7
],
8
8
"scope": "atproto transition:generic",
9
9
"grant_types": [
···
1
1
import React, { useEffect, useState } from 'react';
2
2
-
import { useNavigate } from 'react-router-dom';
2
2
+
import { useNavigate, useLocation } from 'react-router-dom';
3
3
import { useAuth } from '../../contexts/AuthContext';
4
4
import './LoginCallback.css'; // Optional: Add styles if needed
5
5
···
7
7
// Get loading and authentication status from AuthContext
8
8
const { loading, isAuthenticated, error: authError } = useAuth();
9
9
const navigate = useNavigate();
10
10
+
const location = useLocation();
10
11
const [localError, setLocalError] = useState(null);
11
12
12
13
useEffect(() => {
···
18
19
// Once loading is complete, check the authentication status
19
20
if (isAuthenticated) {
20
21
console.log('(LoginCallback) Authentication successful, redirecting...');
21
21
-
// TODO: Implement state parsing for returnUrl if needed
22
22
-
const returnUrl = '/verifier'; // Changed redirect target
22
22
+
23
23
+
// Parse returnUrl from query parameters
24
24
+
const searchParams = new URLSearchParams(location.search);
25
25
+
const returnUrl = searchParams.get('returnUrl') || '/verifier';
26
26
+
27
27
+
console.log(`(LoginCallback) Redirecting to: ${returnUrl}`);
23
28
navigate(returnUrl, { replace: true }); // Use replace to avoid callback in history
24
29
} else {
25
30
// If not authenticated after loading, something went wrong
···
27
32
setLocalError(authError || 'Authentication failed. Please try logging in again.');
28
33
}
29
34
30
30
-
}, [loading, isAuthenticated, navigate, authError]); // Depend on loading and auth state
35
35
+
}, [loading, isAuthenticated, navigate, authError, location]); // Added location dependency
31
36
32
37
// Display loading message
33
38
if (loading) {
···
7
7
8
8
// Client metadata for Bluesky OAuth
9
9
const clientMetadata = {
10
10
-
client_id: `https://cred.blue/client-metadata.json`,
10
10
+
client_id: `https://testing.cred.blue/client-metadata.json`,
11
11
client_name: "cred.blue",
12
12
-
client_uri: `https://cred.blue`,
13
13
-
redirect_uris: [`https://cred.blue/login/callback`],
14
14
-
logo_uri: `https://cred.blue/favicon.ico`,
12
12
+
client_uri: `https://testing.cred.blue`,
13
13
+
redirect_uris: [`https://testing.cred.blue/login/callback`],
14
14
+
logo_uri: `https://testing.cred.blue/favicon.ico`,
15
15
scope: "atproto transition:generic",
16
16
grant_types: ["authorization_code", "refresh_token"],
17
17
response_types: ["code"],