kucherenko / strapi-plugin-passwordless

A plugin for Strapi Headless CMS that provides ability to sign-in/sign-up to an application by link had sent to email.
MIT License
77 stars 27 forks source link

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

Closed chan-fullstack closed 2 years ago

chan-fullstack commented 2 years ago

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: image which is due to parsing a non-JSON entity

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

kucherenko commented 2 years ago

Thank you for the issue, investigating

rndexe commented 2 years ago

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

kucherenko commented 2 years ago

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

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"
    }
}
kucherenko commented 2 years ago

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