should every user login via OAuth2 create two instances of session.create in the Activity tab? When I login, only one instance of session gets created in the Sessions tab, but I see that two events of session.create was called. Is that how it should be?
my code for user auth:
export const googleOAuthLogin = async () => {
try {
const baseUrl = window.location.origin
const userAccount = account.createOAuth2Token(
'google',
`${baseUrl}/user/me`,
`${baseUrl}/`,
)
console.log('Success logging in with Google:', userAccount);
} catch (error) {
console.error('Error logging in with google:', error);
}
}
export const handleOAuthSession = async (userId, secret) => {
try {
await account.createSession(userId, secret);
const user = await account.get();
return user;
} catch (error) {
console.error('Authentication failed:', error);
throw error;
}
};
This is Me.jsx:
useEffect(() => {
const checkingSessionStatus = async () => {
try {
const usr = await getAccount();
if (usr) {
console.log('Session in progress.');
setIsSessionInProgress(true);
setUser(usr);
} else {
setIsSessionInProgress(false);
}
} catch (error) {
console.error(error);
}
};
checkingSessionStatus();
}, [])
//Authenticating User
useEffect(() => {
const params = new URLSearchParams(window.location.search);
const userId = params.get('userId');
const secret = params.get('secret');
const authenticateUser = async () => {
if (hasAuthenticated.current || !userId || !secret) return;
hasAuthenticated.current = true;
try {
const authenticatedUser = await handleOAuthSession(userId, secret);
setUser(authenticatedUser);
} catch (err) { console.error(err);}
};
if (!isSessionInProgress) authenticateUser();
}, [isSessionInProgress]);
Hmm ya I guess it is a little weird. The oauth2 flow creates one event. Then, the create session creates another event
Recommended threads
- Weird permission failure
when creating an account I use following methods: ``` Future<void> register(String email, String password, String username) async { final user = await accoun...
- Flutter Android oAuth is no more working
I currently don't get the oAuth login to work in flutter android. it works on ios and on web. but when try to use it on Android, i get to the point where the ca...
- Paused project can't activate
I have failed to reactivate one my projects which had been paused