Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing refreshToken in response #13

Open
seankanderson opened this issue Sep 23, 2022 · 1 comment
Open

missing refreshToken in response #13

seankanderson opened this issue Sep 23, 2022 · 1 comment

Comments

@seankanderson
Copy link

I was crazy confused until I noticed that these functions are not returning a refreshToken.

function authenticate(req, res, next) {
    const { email, password } = req.body;
    const ipAddress = req.ip;
    accountService.authenticate({ email, password, ipAddress })
        .then(({ refreshToken, ...account }) => {
            setTokenCookie(res, refreshToken);
            res.json(account);  // missing refresh token
        })
        .catch(next);
}

function refreshToken(req, res, next) {
    const token = req.cookies.refreshToken;
    const ipAddress = req.ip;
    accountService.refreshToken({ token, ipAddress })
        .then(({ refreshToken, ...account }) => {
            setTokenCookie(res, refreshToken);
            res.json(account); // missing refresh token
        })
        .catch(next);
}

When I refactored to include the refreshToken it, of course, then showed up in the response.

res.json({...account, refreshToken});

@ofishea
Copy link

ofishea commented Mar 21, 2023

I've been battling same refreshtoken issue as well, i tried this your solution but it didn't work either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants