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 26 forks source link

Plugin not working after installation? #5

Closed sarthology closed 2 years ago

sarthology commented 2 years ago

After enabling everything as mentioned in the Readme, it's not sending requests and showing the following error. How to debug this?

image
kucherenko commented 2 years ago

The issue fixed with strapi-plugin-passwordless@4.0.6

kucherenko commented 2 years ago

The issue was after update of version strapi, one of the services in user-permission plugin changed without clear reasons

bc96123 commented 2 years ago
Screenshot 2022-05-27 at 6 00 01 PM

This is the error I got.

kucherenko commented 2 years ago

@bc96123 first of all I suggest to check versions of the plugin and strapi (I tested it at strapi@v4.1.12 and strapi-plugin-passwordless@4.0.7), also as I can see the error can be if you try to get token for not registered username.

bc96123 commented 2 years ago

@bc96123 first of all I suggest to check versions of the plugin and strapi (I tested it at strapi@v4.1.12 and strapi-plugin-passwordless@4.0.7), also as I can see the error can be if you try to get token for not registered username.

My Project: OS: MacOS 12.3 Node: v16.15.0 Strapi: 4.1.11 Passwordless-Plugin: 4.0.6

kucherenko commented 2 years ago

Try to use the same service with email

POST /api/passwordless/send-link
{
 "email": "your@email.com"
}
bc96123 commented 2 years ago

@kucherenko I got the same error message.

{
    "data": null,
    "error": {
        "status": 400,
        "name": "BadRequestError",
        "message": "wrong.email",
        "details": {}
    }
}
kucherenko commented 2 years ago

could you please show me the passwordless config page?

GraemeFulton commented 2 years ago

I'm getting this error too, it used to work a month ago..not sure when or why it stopped working for me

Screenshot 2022-07-12 at 17 03 10

here's my package.json:

"dependencies": {
    "@strapi/icons": "0.0.1-alpha.79",
    "@strapi/plugin-graphql": "^4.1.12",
    "@strapi/plugin-i18n": "4.1.12",
    "@strapi/plugin-users-permissions": "4.1.12",
    "@strapi/provider-email-mailgun": "^4.1.12",
    "@strapi/strapi": "4.1.12",
    "form-data": "^4.0.0",
    "jwt-decode": "^3.1.2",
    "node-fetch": "^3.2.3",
    "pg": "8.6.0",
    "react-icons": "4.3.1",
    "react-waypoint": "^10.1.0",
    "request": "^2.88.2",
    "strapi-plugin-passwordless": "^4.0.6",
    "strapi-provider-upload-dos": "^4.0.5",

I tried strapi 4.2.2 and strapi-plugin-passwordless 4.0.8 - get the same error, just gives 400 error

kucherenko commented 2 years ago

could you please share the request and response details? how do you try to call the service?

kucherenko commented 2 years ago

I'll try to reproduce, sometimes developers of strapi make some changes, and the plugin becomes broken

GraemeFulton commented 2 years ago

thanks for the quick reply. I'm just trying in postman, and get wrong.user:

Screenshot 2022-07-12 at 17 47 19

I also tried adding it with {"data":, and it says wrong email, instead of wrong.user (above) Screenshot 2022-07-12 at 17 49 13

kucherenko commented 2 years ago

So, the second variant with "data" is wrong. The first variant should work. I've created a fresh strapi@4.2.2 installation and installed "strapi-plugin-passwordless": "^4.0.8" and it works. Could you please remove node_modules and install modules again? I can't reproduce the issue on blank installation, but probably the issue is somewhere else.

GraemeFulton commented 2 years ago

okay thanks a lot

I rolled back to an old commit, with the following versions ( strapi 4.1.7 and passwordless 4.0.5), and that worked fine..but when I use 4.2.2 and 4.0.8, i am getting the error.

I had extended the user-permissions extension, so maybe it is something I have done that is causing the error. THanks for checking with the fresh installations

  "devDependencies": {},
  "dependencies": {
    "@_sh/strapi-plugin-ckeditor": "^1.1.0",
    "@strapi/plugin-graphql": "^4.1.7",
    "@strapi/plugin-i18n": "4.1.7",
    "@strapi/plugin-users-permissions": "4.1.7",
    "@strapi/provider-email-mailgun": "^4.1.7",
    "@strapi/strapi": "4.1.7",
    "form-data": "^4.0.0",
    "jwt-decode": "^3.1.2",
    "node-fetch": "^3.2.3",
    "pg": "8.6.0",
    "request": "^2.88.2",
    "strapi-plugin-passwordless": "^4.0.5",
    "strapi-provider-upload-dos": "^4.0.5"
  },

Screenshot 2022-07-12 at 18 05 04

kucherenko commented 2 years ago

thank you for the report, I'll observe the behavior and fix it in case of issues

GraemeFulton commented 2 years ago

Thanks, I've checked the changes between my old setup and new one, and I can't see anything that is too different

All the permissions are the same..but one environment passwordless works fine, the other it doesn't at all. Can you think of anything obvious? This is the repo: https://github.com/Prototypr/prototypr-backend/tree/main/src/extensions/users-permissions - i suspect it could be user-permissions extension, but it's pretty much the same as the original Strapi plugin

GraemeFulton commented 2 years ago

I have found my issue This sanitizer removes the user.email: https://github.com/kucherenko/strapi-plugin-passwordless/blob/main/server/services/passwordless.js#L166

and because email is null, this check fails: https://github.com/kucherenko/strapi-plugin-passwordless/blob/main/server/controllers/auth.js#L107

If I return user before L166 on the passwordless.js, it works. I don't know why email is sanitized out for me, but that was the cause of my problem

kucherenko commented 2 years ago

will try to investigate sanitizers too

GraemeFulton commented 2 years ago

I put my change on that branch - I can send as a pull request if you think it is worthwhile