testing hehehe
Some checks failed
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Failing after 51m31s
Some checks failed
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Failing after 51m31s
This commit is contained in:
40
src/App.tsx
40
src/App.tsx
@@ -248,6 +248,46 @@ function App() {
|
||||
checkAuthToken();
|
||||
}, [fetchWatchedItems, fetchShoppingLists]); // Add callbacks to dependency array.
|
||||
|
||||
// Effect to handle the token from Google OAuth redirect
|
||||
useEffect(() => {
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const googleToken = urlParams.get('googleAuthToken');
|
||||
|
||||
if (googleToken) {
|
||||
logger.info('Received Google Auth token from URL. Authenticating...');
|
||||
// The token is already a valid access token from our server.
|
||||
// We can use it to fetch the user profile and complete the login flow.
|
||||
localStorage.setItem('authToken', googleToken);
|
||||
getAuthenticatedUserProfile()
|
||||
.then(userProfile => {
|
||||
handleLoginSuccess(userProfile.user, googleToken);
|
||||
})
|
||||
.catch(err => logger.error('Failed to log in with Google token', { error: err }));
|
||||
|
||||
// Clean the token from the URL
|
||||
window.history.replaceState({}, document.title, "/");
|
||||
}
|
||||
|
||||
const githubToken = urlParams.get('githubAuthToken');
|
||||
if (githubToken) {
|
||||
logger.info('Received GitHub Auth token from URL. Authenticating...');
|
||||
// The token is already a valid access token from our server.
|
||||
// We can use it to fetch the user profile and complete the login flow.
|
||||
localStorage.setItem('authToken', githubToken);
|
||||
getAuthenticatedUserProfile()
|
||||
.then(userProfile => {
|
||||
handleLoginSuccess(userProfile.user, githubToken);
|
||||
})
|
||||
.catch(err => {
|
||||
logger.error('Failed to log in with GitHub token', { error: err });
|
||||
// Optionally, redirect to a page with an error message
|
||||
// navigate('/login?error=github_auth_failed');
|
||||
});
|
||||
|
||||
// Clean the token from the URL
|
||||
window.history.replaceState({}, document.title, "/");
|
||||
}
|
||||
}, [handleLoginSuccess]);
|
||||
|
||||
useEffect(() => {
|
||||
if (isReady) {
|
||||
|
||||
Reference in New Issue
Block a user