Closed chan-fullstack closed 2 years ago
Thank you for the issue, investigating
Faced the same issue, ended up using JSON.stringify on the context object before post request.
I've investigated the issue and can't reproduce it, what were the steps:
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:
```json
{
"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"
}
}
So, looks like I can't reproduce the issue, and going to close it
Issue
"context" remains empty even though it exists in the database.
The culprit is this line: https://github.com/kucherenko/strapi-plugin-passwordless/blob/750f4f50b660b626b3cd6d739305d635d40cc2cc/server/controllers/auth.js#L64
It throws a SyntaxError:
which is due to parsing a non-JSON entity
Proposed solution: Update line to
context = JSON.parse(JSON.stringify(token.context))