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

/api/passwordless/login not returning 'context' #6

Closed
chan-fullstack opened this issue Jun 1, 2022 · 4 comments
Closed

/api/passwordless/login not returning 'context' #6

chan-fullstack opened this issue Jun 1, 2022 · 4 comments

Comments

@chan-fullstack
Copy link

chan-fullstack commented Jun 1, 2022

Issue

"context" remains empty even though it exists in the database.

The culprit is this line:

context = JSON.parse(token.context);

It throws a SyntaxError:
image
which is due to parsing a non-JSON entity

Proposed solution:
Update line to context = JSON.parse(JSON.stringify(token.context))

@kucherenko
Copy link
Owner

Thank you for the issue, investigating

@rndexe
Copy link

rndexe commented Jun 4, 2022

Faced the same issue, ended up using JSON.stringify on the context object before post request.

@kucherenko
Copy link
Owner

I've investigated the issue and can't reproduce it, what were the steps:

  • call send link service
POST /api/passwordless/send-link

Body:
{
  "email": "user@email.com",
  "username": "John Bull",
  "context": { 
    "test": "test context"
  }
}

  • call login service
GET /api/passwordless/login?loginToken=my_token_from_email

The result:

{
    "jwt": "my jwt token",
    "user": {
        "id": 1,
        "username": "John Bull",
        "email": "user@email.com",
        "provider": null,
        "confirmed": true,
        "blocked": false,
        "createdAt": "2022-06-29T13:18:51.909Z",
        "updatedAt": "2022-06-29T13:20:36.033Z"
    },
    "context": {
        "test": "test context"
    }
}

@kucherenko
Copy link
Owner

So, looks like I can't reproduce the issue, and going to close it

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

3 participants