• a

    aschepis

    8 months ago
    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

    8 months ago
    that's exactly the recommended way of doing it 🙂
  • p

    porcellus

    8 months ago
    We don't store that on the frontend by default, but there are a few options
  • p

    porcellus

    8 months ago
    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

    8 months ago
    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

    8 months ago
    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

    8 months ago
    👍
  • p

    porcellus

    8 months ago
    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

    8 months ago
    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

    8 months ago
    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);
                    },
                }),
            },
            // ...
        },