guillaumebriday / todolist-backend-laravel

Back-end application for Todolist Web application built with Laravel 5.8 and Vue.js
https://todolist-docs.guillaumebriday.me
MIT License
70 stars 22 forks source link

User registration broken #51

Closed connecteev closed 5 years ago

connecteev commented 5 years ago

Just tried the code on the master branch after going through the installation steps here.

I am seeing this error when I register:

Request URL: http://localhost:8001/api/v1/auth/me
Request Method: GET
Status Code: 401 Unauthorized
Remote Address: 127.0.0.1:8001
Referrer Policy: no-referrer-when-downgrade

Note that the user account DOES get created in the Database, but the /api/v1/auth/me endpoint fails, and subsequently the user stays on the /register page.

Error in console:

Request URL: http://localhost:8001/api/v1/auth/register
Request Method: POST
Status Code: 200 OK

Request URL: http://localhost:8001/api/v1/auth/login
Request Method: POST
Status Code: 200 OK

VM445:1 GET http://localhost:8001/api/v1/auth/me 401 (Unauthorized)
(anonymous) @ VM445:1
dispatchXhrRequest @ commons.app.js:551
xhrAdapter @ commons.app.js:390
dispatchRequest @ commons.app.js:998
Promise.then (async)
request @ commons.app.js:800
wrap @ commons.app.js:1343
request @ app.js:676
requestWith @ app.js:709
_callee3$ @ app.js:1216
tryCatch @ commons.app.js:6588
invoke @ commons.app.js:6814
prototype.<computed> @ commons.app.js:6640
asyncGeneratorStep @ commons.app.js:51
_next @ commons.app.js:73
(anonymous) @ commons.app.js:80
(anonymous) @ commons.app.js:69
fetchUser @ app.js:1231
_callee$ @ app.js:1133
tryCatch @ commons.app.js:6588
invoke @ commons.app.js:6814
prototype.<computed> @ commons.app.js:6640
asyncGeneratorStep @ commons.app.js:51
_next @ commons.app.js:73
Promise.then (async)
asyncGeneratorStep @ commons.app.js:61
_next @ commons.app.js:73
Promise.then (async)
asyncGeneratorStep @ commons.app.js:61
_next @ commons.app.js:73
(anonymous) @ commons.app.js:80
(anonymous) @ commons.app.js:69
login @ app.js:1144
login @ app.js:516
(anonymous) @ app.js:503
Promise.then (async)
loginWith @ app.js:502
login @ login.js:238
submit @ login.js:337
invokeWithErrorHandling @ commons.app.js:14041
invoker @ commons.app.js:14366
original._wrapper @ commons.app.js:19089
vendors.app.js:23422 error TypeError: Cannot read property 'hasOwnProperty' of undefined
    at Errors.has (register.js:755)
    at Proxy.render (login.js:366)
    at VueComponent.Vue._render (commons.app.js:15724)
    at VueComponent.updateComponent (commons.app.js:16231)
    at Watcher.get (commons.app.js:16655)
    at Watcher.run (commons.app.js:16730)
    at flushSchedulerQueue (commons.app.js:16486)
    at Array.<anonymous> (commons.app.js:14167)
    at flushCallbacks (commons.app.js:14093)
guillaumebriday commented 5 years ago

Hey! Thank you for your issue, I'll try on a brand new installation later today.

Note that's it does work on production environment.

Which node version do you have ?

Thanks

connecteev commented 5 years ago

Pleasure! Note I have an older version of your codebase working from a few months ago so something broke after that. I'm on a mac with the current node/npm version:

$ node -v
v10.16.2
OneStepAtATime:guillaumebriday_todolist $ npm -v
6.11.3
connecteev commented 5 years ago

It actually works fine. Turns out I was missing this step: (previously when prompted I pressed enter so it defaulted to "no", so the jwt secret key was never generated. Not sure if that can be "forced" or added to the Readme, but that might help if others get stuck).

$ php artisan jwt:secret

 This will invalidate all existing tokens. Are you sure you want to override the secret key? (yes/no) [no]:
 > yes

jwt-auth secret [HU1qui6S5QPzyO0r8pI1ihVo0hDIH02pYzK2VJw9h8riEUenOWK9lPi2siPZVGGr] set successfully.
guillaumebriday commented 5 years ago

Haaa that's cool thank you

guillaumebriday commented 5 years ago

Do you use a self hosted application for the api ?

connecteev commented 5 years ago

@guillaumebriday I use Laravel on my Dev machine for the backend APIs....and Nuxt for the front-end talking to the APIs. Is that what you are asking?

guillaumebriday commented 5 years ago

Hum I was wondering if you are using this app in production on your own servers ?

I wanted to know if I should deploy the image on the docker hub to simplify deployments for everyone.

connecteev commented 5 years ago

I do have an app (laravel + nuxt) of my own on production, though it's not this one.

Never used Docker (docs seem complex and I never really spent the time to get it running. I'm not sure of the benefit tbh...but I dont know a lot about it).