rluders / wn-jwtauth-plugin

JWTAuth Plugin for WinterCMS
GNU General Public License v3.0
29 stars 28 forks source link

Not getting error response on login and register #18

Closed ivandoric closed 5 years ago

ivandoric commented 5 years ago

Hi,

So I have the following problem. When trying to login the user, if I send correct data everything works fine. I get the response, get the token, I get the user data. All good.

But if the user inputs wrong information, like instead of email he enters username. Then I just get CORS error.

http://api.localhost/api/auth/login 422 (Unprocessable Entity)

and

Access to XMLHttpRequest at 'http://api.localhost/api/auth/register' from origin 'http://localhost:8080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Which is weird. Now I did more testing and for the login if I enter wrong email and password. I actually get the response of invalid_credentials, which is good, but I don't get a response if using username instead of email. At least not when contacting the API through my app, which is on another domain.

But if I do it through Postman, then I get:

{
    "error": {
        "login": [
            "The login must be a valid email address."
        ]
    }
}

Which is great, and I want to get the same thing through my app. But I keep getting CORS error.

Now for CORS I have this plugin installed: https://octobercms.com/plugin/offline-cors

I tried installing yours, and allowing everything, but it just didn't work at all, none of the requests passed. So I had to use the above mentioned plugin.

Also the same thing is happening with registration, when all the data is correct everything is fine and works well. But if for example you try to register user with existing email, you just get the CORS error.

Any help would be appreciated.

ivandoric commented 5 years ago

Ok, so I made some more tests, trying to send only JSON, From Data, Different headers etc. and nothing worked. Because I thought that the problem may lie in my requests. But it turns out that the problem is actually in your plugin.

I tried this plugin: https://octobercms.com/plugin/vdomah-jwtauth

And everything works as expected. Which is a shame, because I prefer your plugin because it has more options.

If you need anything else please let me know. I have setup everything online so that you can test it if you want, let me know and I will give you the info about that on twitter DM or somewhere private because I don't know if Github has private messages.

rluders commented 5 years ago

OK.

That is strange. I'll check what is happening, I just need to organizing my setup to test it.

If you need to send me any pm messages you can find me on Freenode (rluders) or at the OctoberCMS' Slack.

Thanks.

On Tue, Jan 22, 2019, 13:18 Ivan Dorić notifications@github.com wrote:

Ok, so I made some more tests, trying to send only JSON, From Data, Different headers etc. and nothing worked. Because I thought that the problem may lie in my requests. But it turns out that the problem is actually in your plugin.

I tried this plugin: https://octobercms.com/plugin/vdomah-jwtauth

And everything works as expected. Which is a shame, because I prefer your plugin because it has more options.

If you need anything else please let me know. I have setup everything online so that you can test it if you want, let me know and I will give you the info about that on twitter DM or somewhere private because I don't know if Github has private messages.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/rluders/oc-jwtauth-plugin/issues/18#issuecomment-456379531, or mute the thread https://github.com/notifications/unsubscribe-auth/AALqM2rFNoGlSTAsFdH0klcJ3IVk1dWTks5vFwGWgaJpZM4aMPzv .

ivandoric commented 5 years ago

Cool, thanks. I've sent you additional info on Octobers Slack, and tried to give additional data about the problem which will hopefully help you.

rluders commented 5 years ago

I did released a hotfix for it. So, it should be fine right now.