Rank 2: Process
Ive configured OAuth login and then trying to save user data in DB requested from oauth provider. So I configured run Function on event users . * . sessions . * . create. Is it correct?
Because after it I'm trying to get OAuth provider data (from payload) such as provider name, access_token, userId and so on. Getting current payload from the OAuth: const payload = JSON.parse(process.env.APPWRITE_FUNCTION_EVENT_DATA). But even if session has been deleted on the client side function execution logs say that it's still the same user. Even if user try to login with another OAuth provider. I get current user session using new Account(client).getSession('current') and then accountApi.deleteSession(sessionId). What I did wrong?
Try to simplify:
add OAuth provider (2 for now) -> execute function on users . * . sessions . * . create event -> get function payload -> logout user on client side -> login with another provider -> payload in new executed function still the same as before (for another OAuth provider)
I've found