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/17/2021, 3:42 PM
    (it's an empty repo atm)
  • r

    rp

    03/17/2021, 3:43 PM
    And i'd also be happy to get on a call to take you through the React native code in detail so that it's easier for you to port it to flutter :).
  • b

    bachras

    03/17/2021, 3:55 PM
    @User I have sent you private message
  • d

    deltasoneca

    03/19/2021, 12:37 PM
    Hello, I am new to Supertokens and I hope I can get some help here. I am using Supertokens SaaS version and implementing it on NextJS. I used NextJS template and it's working fine. This template has a function to fetch user data happening on the client, but I want to fetch user data from the server. In NextJS that means running inside
    getServerSideProps()
    . It is not advised to use
    fetch()
    there as the template does in the client side. So what should I do? I was able to make it work using the code below, but I am not sure it's the best way to do it -- I just adapted the code present in the template. Also this does not return the email used for login (I am not using social login). I need the email.
    await superTokensNextWrapper(
        async next => {
        return await verifySession()(context.req, context.res, next);
        },
        context.req,
        context.res
    );
    
    const { userId } = await context.req.session;
    Any help is appreciated! Thanks!
  • a

    Adiboi

    03/19/2021, 1:29 PM
    Hi Deltasoneca! @rp is away right now but he will be available in a 4-5 hours. Please hang on till then!
  • k

    kakashi_44

    03/19/2021, 2:01 PM
    hey @User , if you are using emailpassword recipe, you can get user's email by using getUserById function. Doc link: https://supertokens.io/docs/nodejs/emailpassword/getuserbyid.
  • o

    othiagocruz

    03/19/2021, 2:21 PM
    hey is there any examples on fetching an user session information? im using express and trying to find out if the given sessionHandle is valid
  • k

    kakashi_44

    03/19/2021, 2:44 PM
    hey @User, if you are already using supertokens middleware for the route, req.session will be a valid user's session object. If you just intend validate a sessionHandle, you can call function like getSessionData (link: https://supertokens.io/docs/nodejs/session/getsessiondata). The function will return sessionData if the sessionHandle is valid else, it will throw an unauthorised error. So call this function inside a try-catch block to avoid any unhandled error.
  • o

    othiagocruz

    03/19/2021, 2:45 PM
    the thing is that express is remote
  • o

    othiagocruz

    03/19/2021, 2:45 PM
    id need something like firebase verifyToken function
  • d

    deltasoneca

    03/19/2021, 3:39 PM
    Thanks, I was wondering my
    req.session.sessionData
    was empty (I expected the email to be there), but
    getUserById
    should do the trick, tks!
  • t

    theefunklord

    03/19/2021, 3:46 PM
    Hello there! Hope everyone is staying safe. I've been doing my best to make sure I understand everything from the documentation, but I still have a few questions that should be simple enough to answer😄 , so here goes: I have an existing react/Next.js app which is successfully pulling GraphQL post data from my WordPress site. I am trying to find the simplest way to validate user login for the app against my existing SQL/WP users. Using the next.js example with-supertokens, I'm slightly confused as to the best way to implement this connection. My app is on a subdomain, so I am trying to avoid creating a new database there, if needed. 1. Do I need a self-hosted core instance of supertokens? (not running Docker, but on Node.js- I have reviewed the download section and parameters) 2. Is the Apollo example listed in the documentation a good place to start? (https://supertokens.io/docs/website/graphql) I guess the "Next.JS" way would be to configure this: https://supertokens.io/docs/community/database-setup/mysql#2-connect-supertokens-to-your-database into an env file, but I feel like I'm missing something. (apologies if any of this has been covered already, I will keep searching)
  • o

    othiagocruz

    03/19/2021, 4:47 PM
    did some investigation on this it seems for me to validate this i can use the getAllSessionHandlesForUser mehod for that
  • r

    rp

    03/19/2021, 5:03 PM
    @User i think it's best if we get on a quick call. I think your scenario is slightly too complex for text on discord. I can do Sunday evening IST. Does that work for you?
  • r

    rp

    03/19/2021, 5:03 PM
    @User did your query get resolved?
  • o

    othiagocruz

    03/19/2021, 5:05 PM
    i just need to confirm if thats how i validate a logged in user, by using the getAllSessionHandlesForUser
  • t

    theefunklord

    03/19/2021, 5:05 PM
    @User That would be outstanding, thanks
  • r

    rp

    03/19/2021, 5:06 PM
    ok great! I'll DM to here to find a mutual time
  • r

    rp

    03/19/2021, 5:08 PM
    @User validating a logged in user is done via the
    Session.verifySession()
    function in your APIs.
  • o

    othiagocruz

    03/19/2021, 5:09 PM
    but what if i need to validate that remotely? like say its a webhook that confirms the user is logged in
  • r

    rp

    03/19/2021, 5:09 PM
    what do you mean remotely?
  • o

    othiagocruz

    03/19/2021, 5:09 PM
    https://github.com/hasura/graphql-engine/blob/master/community/boilerplates/auth-webhooks/nodejs-firebase/firebase/firebaseHandler.js
  • o

    othiagocruz

    03/19/2021, 5:10 PM
    something along these lines
  • r

    rp

    03/19/2021, 5:10 PM
    so a user's session tokens are needed to know if they are logged in or not
  • r

    rp

    03/19/2021, 5:10 PM
    oh right..
  • o

    othiagocruz

    03/19/2021, 5:11 PM
    i tried running the getAllSessionHandlesForUser and sending the userId
  • o

    othiagocruz

    03/19/2021, 5:11 PM
    it returns my sessions
  • r

    rp

    03/19/2021, 5:11 PM
    so if you want to know if a user is logged into at least one device, you will have to get their user ID and use
    getAllSessionHandlesForUser
    . If this returns an array of size > 0, then they are logged in into at least one device.
  • o

    othiagocruz

    03/19/2021, 5:11 PM
    noice
  • o

    othiagocruz

    03/19/2021, 5:11 PM
    exactly what i needed
Powered by Linen
Title
o

othiagocruz

03/19/2021, 5:11 PM
exactly what i needed
View count: 1