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
general
  • a

    aschepis

    01/21/2022, 8:23 PM
    now i just have to figure out how to get email to the front-end so i can display that to the user.
  • p

    porcellus

    01/21/2022, 8:37 PM
    that's exactly the recommended way of doing it ๐Ÿ™‚
  • p

    porcellus

    01/21/2022, 8:41 PM
    We don't store that on the frontend by default, but there are a few options
  • p

    porcellus

    01/21/2022, 8:43 PM
    You could add it to the access token payload and use that through
    useSessionContext
    , but this will get transmitted with every request. (https://supertokens.io/docs/emailpassword/common-customizations/user-roles/assigning-session-roles)
  • p

    porcellus

    01/21/2022, 8:45 PM
    You also get this info when login succeeds so you could store this locally after a login succeeds(https://supertokens.io/docs/emailpassword/common-customizations/handling-signin-success#1-on-the-frontend). If you go with this I'd recommend tying the stored info the the session id, so the if something goes wrong you don't display the wrong email)
  • p

    porcellus

    01/21/2022, 8:47 PM
    Also, you can just add an API endpoint and store the result in memory. Most apps fetch some info about the current user anyway, so you could do it at the same time.
  • a

    aschepis

    01/21/2022, 8:52 PM
    ๐Ÿ‘
  • p

    porcellus

    01/21/2022, 8:57 PM
    Not necessarily, check out our "session management only" recipe https://supertokens.io/docs/session/quick-setup/frontend You can define your own auth/routes and validate the session on multiple node servers if they have access to the cookie.
  • p

    porcellus

    01/21/2022, 9:01 PM
    Not out of the box. You can implement this by changing the password of the user (
    updateEmailOrPassword
    ), then revoking all their sessions (
    revokeAllSessionsForUser
    )
  • p

    porcellus

    01/21/2022, 9:15 PM
    Hi, you can do this by overriding
    signUpPOST
    . Something like this should work:
    EmailPassword.init({
            override: {
                apis: (originalImplementation) => ({
                    ...originalImplementation,
                    signUpPOST: async function (input) {
                        const email = input.formFields.find((f) => f.id === "email").value;
                        const password = input.formFields.find((f) => f.id === "password").value;
    
                        return EmailPassword.signUp(email, password);
                    },
                }),
            },
            // ...
        },
  • w

    workoutintheabstract

    01/21/2022, 9:16 PM
    thank you porcellus, i have another question
  • w

    workoutintheabstract

    01/21/2022, 9:16 PM
    message has been deleted
  • w

    workoutintheabstract

    01/21/2022, 9:17 PM
    i want to secure my routes with this method from the session recipe under common customizations
  • w

    workoutintheabstract

    01/21/2022, 9:17 PM
    the redirect function i provide just needs to return a react-router-dom redirect component correct?
  • p

    porcellus

    01/21/2022, 9:19 PM
    No, it's a
    () => void
    function, it needs to do the redirect itself (or do nothing, show a popup, whatever suits your needs)
  • a

    aschepis

    01/22/2022, 1:50 AM
    once i have a user signed up via third party provider, how do i get their email, name, etc?
  • r

    rp

    01/22/2022, 5:43 AM
    @User you can get the access token sent by the third party provider like this: https://supertokens.io/docs/thirdpartyemailpassword/post-login/getting-provider-access-token Then you can query the provider and get any info you like.
  • s

    sam123

    01/22/2022, 1:27 PM
    I have an app where the user, after logging in, can generate a token with a customizable lifetime (30 days, 60 days, Never) It is similar to generating a personal access token in github. The user should be able to revoke the token whenever required. This token will be used by the user to call a set of apis. How would I go about implementing this? Does supertokens support this?
  • r

    rp

    01/22/2022, 1:32 PM
    Yes. We do support this. The tokens that would be issued are JWTs. You can enable JWT support from our session recipe (in session.init). You can then create a new JWT (using the session recipe) with custom payload and custom lifetime in your API post session verification. You can return this JWT to the user as their personal access token.
  • r

    rp

    01/22/2022, 1:34 PM
    The only issue with this is that you canโ€™t revoke them by default. In order to do that, you can store a custom ID in the JWT, and also in your db. During JWT verification, you can check if that custom ID still exists in the db.
  • r

    rp

    01/22/2022, 1:35 PM
    However, if you do that, you can also send just the custom ID as there access token anyway.. so it kind of beats the purpose of making a JWT, unless you want to use the JWT as also a way to store some custom payload info
  • s

    sam123

    01/22/2022, 1:40 PM
    @User Thank you for the response. The token will not need to store any custom payload other than a way to identify the user. Like github, I also want to alert the user via an email when his token is about to expire.
  • r

    rp

    01/22/2022, 1:43 PM
    I see. So then it would make more sense to just handle this part yourself without supertokens, as we donโ€™t add any value to this yet.
  • s

    sam123

    01/22/2022, 1:52 PM
    Thank you @User. Any advice how to go about it and what security considerations to factor in.
  • r

    rp

    01/22/2022, 2:01 PM
    @User - Make sure the access token is generated with enough entropy and is long enough (>= 32 chars should be enough). You can use something equivalent to SecureRandom in Java (https://docs.oracle.com/javase/8/docs/api/java/security/SecureRandom.html) - You can store the associated userId and lifetime in your db against the token. Do not send these to the frontend. - From a performance point of view, you can cache this info and query the cache on each API call that uses the access token. - Send this token as an Authentication bearer token in API requests (see https://swagger.io/docs/specification/authentication/bearer-authentication/). - Make sure to check if the lifetime of the token has expired each time you authenticate the token from the db. - Set up a cronjob to remove expired tokens.
  • s

    sam123

    01/22/2022, 2:03 PM
    Thank you @User
  • s

    soham

    01/22/2022, 2:28 PM
    https://discord.gg/w2qmecRB?event=934453835143995432
  • s

    soham

    01/22/2022, 2:30 PM
    Supertoken ๐Ÿค Invide. I'm in both sides !
  • s

    samurize

    01/22/2022, 5:23 PM
    @User
  • s

    samurize

    01/22/2022, 5:24 PM
    I have one suggestion to make on the Readme.md
Powered by Linen
Title
s

samurize

01/22/2022, 5:24 PM
I have one suggestion to make on the Readme.md
View count: 2