Questions about the docs...
# general
d
Questions about the docs...
Hi! I have a question about the docs... I have successfully (thanks to your help) been able to create Firebase sessions via SuperTokens. Now I want to ensure that I am properly handling signout and token refreshes as well. I assume that I need to override some existing methods, for instance in the way that is shown on this page: https://supertokens.com/docs/thirdpartyemailpassword/advanced-customizations/backend-functions-override/usage That page has a link:
Copy code
See all the functions that can be overrided here: https://supertokens.com/docs/nodejs/modules/recipe_thirdpartyemailpassword.html#RecipeInterface
I am guessing that the information I need about Sessions is here: https://supertokens.com/docs/nodejs/modules/recipe_session.html Is that correct? What I am trying to understand, and it is not clear to me from the docs, is: 1. What functions can I override? And 2. What precisely do those functions do, and when are they called? I was hoping that by reading the docs, I could understand what I need to do to properly manage my Firebase sessions.
r
> Is that correct? Yes. So before seeing what to override, what do you want to do in those functions? Do you want to refresh the firebase token when the supertokens session is refreshed? And in sign out, do you want to revoke the firebase token when sign out is called? Since firebase issues a JWT, how will that be revoked from Firebase's side exactly - do they have a function in the admin SDK for that?
d
> So before seeing what to override, what do you want to do in those functions? Do you want to refresh the firebase token when the supertokens session is refreshed? Yes, precisely. > And in sign out, do you want to revoke the firebase token when sign out is called? Since firebase issues a JWT, how will that be revoked from Firebase's side exactly - do they have a function in the admin SDK for that? Yes, just like the token was created by the Firebase admin SDK, the token can also be revoked.
r
Got it. So you want to override as follows:
Copy code
ts
Session.init({
    override: {
        functions: (oI) => {
            return {
                ...oI,
                refreshSession: async function (input) {
                    let session = oI.refreshSession(input);
                    // TODO: update firebase token in session...
                    return session;
                }
            }
        },
        apis: (oI) => {
            return {
                ...oI,
                signOutPOST: async function (input) {
                    let session = await Session.getSession(input.options.req, input.options.res, input.userContext);
                    // TODO: revoke firebase session..
                    return oI.signOutPOST!(input);
                }
            }
        }
    }
})
d
Ok, perfect. Thank you!!
r
happy to help 🙂