https://supertokens.com/ logo
Docs
Join the conversationJoin Discord
Channels
community
contributing
general
github-activity
info
introductions
new-releases
random
security
support-questions
welcome-0xdelusion
welcome-aj-ya
welcome-aleksandrc
welcome-alpinjs
welcome-amberlamps1
welcome-andrew-rodriguez
welcome-ankit-choudhary
welcome-anthony-stod-custodio
welcome-call-in
welcome-chwalbox
welcome-claybiokiller
welcome-co7e
welcome-cosmoecwsa
welcome-devdag
welcome-dinso
welcome-drebotelho
welcome-elio
welcome-ernest
welcome-foxbarrington
welcome-fromscratch
welcome-galto4ir
welcome-goetzum
welcome-hay-kot
welcome-himanshu-kukreja
welcome-hossambarakat
welcome-ichikawakazuto
welcome-jahir9991
welcome-jamesl
welcome-jerry123424
welcome-john-oliver
welcome-jonas-alexanderson
welcome-jxyz
welcome-kelvinwop
welcome-kraz
welcome-lancekey
welcome-leoo
welcome-lukeacollins
welcome-m-j-mon
welcome-malik-khoja
welcome-marco
welcome-mardadi
welcome-meshguy
welcome-metamorph
welcome-mike-tectu
welcome-mirzok
welcome-mozomig
welcome-naberyou66_
welcome-nacer
welcome-namratha
welcome-naveenkumar
welcome-nightlight
welcome-nischith
welcome-notankit
welcome-olawumi
welcome-pavan-kumar-reddy-n
welcome-pineappaul
welcome-poothebear
welcome-rick
welcome-samuel-qosenergy
welcome-samuelstroschein
welcome-shubhamgoel23
welcome-shubhamkaushal
welcome-sidebar
welcome-surajsli
welcome-suyash_
welcome-syntaxerror
welcome-tauno
welcome-tauno
welcome-tawnoz
welcome-teclali
welcome-tls
welcome-turbosepp
welcome-vikram_shadow
welcome-yann
Powered by Linen
support-questions
  • r

    rp

    03/05/2021, 1:52 PM
    Perfect!
  • t

    thisjust

    03/05/2021, 1:55 PM
    But those examples ... still is a little confusing which parts of them apply to me, as someone not using supertokens for auth. For example, yes I'm using
    serverless-http
    to translate from serverless functions into
    (req, res)
    style functions, but I'm not using
    express
    ,
    body-parser
    , or
    supertokens.middleware
    . Do I need to be using these? Or is the fact that I'm getting these 4 cookies mean everything is okay?
  • r

    rp

    03/05/2021, 1:57 PM
    You need to have everything on the backend except for the EmailPassword.init part. And also except for the exactly /sessionInfo API
  • r

    rp

    03/05/2021, 1:57 PM
    So you need bodyParser and you need supertokens.middleware
  • r

    rp

    03/05/2021, 2:01 PM
    And you also need the supertokens.errorHandler
  • t

    thisjust

    03/05/2021, 2:01 PM
    Is there some way to test out that my current setup is not working correctly due to the absence of those two things? What "should" be broken, as a result of not using
    bodyParser
    or
    supertokens.middleware
    ?
  • r

    rp

    03/05/2021, 2:02 PM
    So if you delete the sAccessToken from the browser, and make an API request to a route that requires a session, that will fail with a 401, the SDK will try and call the refresh API which will return 404. Since you don’t have supertokens.middleware
  • r

    rp

    03/05/2021, 2:03 PM
    Once you add that and bodyParser, then the refresh call will yield a 200 and not 404. And the frontend SDK should then again call the original API which should then return 200 since a new sAccessToken is available
  • t

    thisjust

    03/05/2021, 2:03 PM
    Gotcha. Okay I will try it out
  • t

    thisjust

    03/05/2021, 9:54 PM
    Is there a reason the user's faunadb Ref# is exposed on the frontend? Seems like an unnecessary thing to have there, when all I need is the (short-lived) faunadb token
  • r

    rp

    03/06/2021, 5:40 AM
    That ref is the userId associated with the session. For several apps, they require a user’s ID on the frontend so we provided that feature. Is it a security issue for your use case @thisjust ?
  • t

    thisjust

    03/06/2021, 9:43 PM
    Hi @User, I don't need it, since FaunaDB infers that info from the token. Not a security issue per se that I can think of, just seems like a good practice to not expose internal db info when it's not needed. If there were a supertokens config setting or something to easily keep that info out of the frontend, I would make use of it, but I don't think it's a big deal
  • r

    rp

    03/06/2021, 9:44 PM
    Cool. Let me see what I can do about this. If there is a quick config I can add.
  • t

    thisjust

    03/06/2021, 9:45 PM
    Okay thanks! To change the subject: to log a user out, it looks like I need to implement a "/logout" route on the backend, yes? Or is there something I can call on the frontend that already accomplishes this?
  • t

    thisjust

    03/06/2021, 9:46 PM
    As far as implementing "/logout", I found this: https://supertokens.io/docs/thirdpartyemailpassword/common-customizations/sessions/revoke-session
  • r

    rp

    03/06/2021, 9:46 PM
    You would need to implement this on the backend. Any API that verifies a session, and then calls revokeSession in the API
  • r

    rp

    03/06/2021, 9:47 PM
    Yea. That link is correct. You should follow the method using the req object.
  • t

    thisjust

    03/06/2021, 9:49 PM
    Are there pros/cons to
  • r

    rp

    03/06/2021, 9:50 PM
    The req object one is the only method that clears the tokens from the frontend + the db. The other ones only clear from the db.
  • t

    thisjust

    03/06/2021, 9:50 PM
    let sessionHandle = req.body.sessionHandle
    await Session.revokeSession(sessionHandle);
    vs verifying session with middleware and then``` await req.session.revokeSession(); ```
  • r

    rp

    03/06/2021, 9:52 PM
    I think I’ll change the docs to make it more clear as to which method to use for signout API vs other ways and their use case.
  • t

    thisjust

    03/06/2021, 9:55 PM
    Okay cool, this one, yes?
    await req.session.revokeSession();
  • r

    rp

    03/06/2021, 9:55 PM
    Yes.
  • r

    rp

    03/06/2021, 9:56 PM
    And on ur frontend, when you call this API, you should check if the status code is 401 (or 200). Either of them means that sign out was successful
  • r

    rp

    03/06/2021, 9:57 PM
    Since if ur getting 401, it means the session has expired (which is equivalent to a sign out)
  • t

    thisjust

    03/06/2021, 9:58 PM
    Okay I will check for that on the front end.
  • t

    thisjust

    03/06/2021, 10:12 PM
    Hmm I'm getting
    supertokens.verifySession is not a function
  • t

    thisjust

    03/06/2021, 10:19 PM
    Okay I figured out it should be
    Session.verifySession
    , from searching your repo for
    verifySession
    . But your docs say to use
    supertokens.verifySession
  • r

    rp

    03/07/2021, 5:03 AM
    Oh! Thanks for pointing that out. Will fix it @thisjust
  • r

    rp

    03/07/2021, 6:29 AM
    @User I have created an issue about not passing the userId on the frontend via a config: https://github.com/supertokens/supertokens-core/issues/200 Since this is not necessary for you, we can see if others would like this as well and if they do, then we can implement it. 🙂
Powered by Linen
Title
r

rp

03/07/2021, 6:29 AM
@User I have created an issue about not passing the userId on the frontend via a config: https://github.com/supertokens/supertokens-core/issues/200 Since this is not necessary for you, we can see if others would like this as well and if they do, then we can implement it. 🙂
View count: 1