laravel-enso / enso

Laravel Vue SPA, Bulma themed. For demo login use `admin@laravel-enso.com` & `password` -
https://www.laravel-enso.com
MIT License
1.08k stars 277 forks source link

Finally got it working but I am unable to login #320

Closed gabrielfigueroa closed 4 years ago

gabrielfigueroa commented 4 years ago

I am attempting to login using the admin@laravel-enso.com and password credentials. I seeded my tables and I see the entry on the users table for admin@laravel-enso.com.

Nothing happens after I hit Login.

My URL for testing Enzo SPA is: http://admin.digihometour.com/login

aocneanu commented 4 years ago

You'll have to configure in your .env SANCTUM_STATEFUL_DOMAINS=http://admin.digihometour.com

@gandesc we need to update the install steps regarding this.

Please prioritize it as much as you can.

gabrielfigueroa commented 4 years ago

This entry in the .env goes in the main folder or in the client folder?

aocneanu commented 4 years ago

It's related to Laravel Sanctum so it goes in the root .env

In dev mode add localhost, domain.test

https://laravel.com/docs/7.x/sanctum#spa-configuration

gabrielfigueroa commented 4 years ago

I did what you suggested and still have the same error. When I try to login to the enso demo with incorrect credentials I get an error. When I do it in my installation it doesn't return the same error, instead it does nothing. I launched the client and it said

App running at:

While the .env has API_URL=http://admin.digihometour.com:8000/

I installed all dependencies and requirements and got no errors and I can't find an error in the laravel.log.

aocneanu commented 4 years ago

If you inspect in the console => network => api call you will see that you are missing the device_name.

This is happening because you did nou configure correctly sanctum's stateful domains.

gandesc commented 4 years ago

Hi Gabriel,

In my notes below, replace enso with your project name

First, in your project root .env file, make sure you have:

...
APP_URL=http://admin.enso.test
...
SANCTUM_STATEFUL_DOMAINS=localhost,127.0.0.1,127.0.0.1:8000,localhost:8080,::1,enso.test,admin.enso.test

Second, in your client/ .env file, make sure you have:

API_URL=http://enso.test:80/

I installed all dependencies and requirements and got no errors and I can't find an error in the laravel.log.

The error would have been in your browser's console (network).

Do let us know if you got it working.

gabrielfigueroa commented 4 years ago

I'm followed this instructions and after running yarn serve in the client/ directory now I get the following error:

$ vue-cli-service serve INFO Starting development server... 10% building 2/2 modules 0 activeevents.js:174 throw er; // Unhandled 'error' event ^

Error: ENOSPC: System limit for number of file watchers reached, watch '/var/www/html/back-end/client' at FSWatcher.start (internal/fs/watchers.js:165:26) at Object.watch (fs.js:1258:11) at createFsWatchInstance (/var/www/html/back-end/client/node_modules/chokidar/lib/nodefs-handler.js:38:15) at setFsWatchListener (/var/www/html/back-end/client/node_modules/chokidar/lib/nodefs-handler.js:81:15) at FSWatcher.NodeFsHandler._watchWithNodeFs (/var/www/html/back-end/client/node_modules/chokidar/lib/nodefs-handler.js:233:14) at FSWatcher.NodeFsHandler._handleDir (/var/www/html/back-end/client/node_modules/chokidar/lib/nodefs-handler.js:429:19) at FSWatcher. (/var/www/html/back-end/client/node_modules/chokidar/lib/nodefs-handler.js:477:19) at FSWatcher. (/var/www/html/back-end/client/node_modules/chokidar/lib/nodefs-handler.js:482:16) at FSReqWrap.oncomplete (fs.js:154:5) Emitted 'error' event at: at FSWatcher._handleError (/var/www/html/back-end/client/node_modules/chokidar/index.js:260:10) at createFsWatchInstance (/var/www/html/back-end/client/node_modules/chokidar/lib/nodefs-handler.js:40:5) at setFsWatchListener (/var/www/html/back-end/client/node_modules/chokidar/lib/nodefs-handler.js:81:15) [... lines matching original stack trace ...] at FSReqWrap.oncomplete (fs.js:154:5) error Command failed with exit code 1.

gabrielfigueroa commented 4 years ago

I am rebooting the system to see if that system limit of number of file watchers is reset.

gabrielfigueroa commented 4 years ago

Followed the instructions to the letter and when I inspect after attempting to login I get the following error:

POST http://admin.digihometour.com/api/login 422 (Unprocessable Entity)

gandesc commented 4 years ago

What is the error message in the server response? You can inspect it in the browser console, on the network tab.

gabrielfigueroa commented 4 years ago

{message: "The given data was invalid.", errors: {device_name: ["The device name field is required."]}} errors: {device_name: ["The device name field is required."]} message: "The given data was invalid.

Can't find anything regarding device_name in the installation instructions.

gandesc commented 4 years ago

The error is still related to SANCTUM_STATEFUL_DOMAINS and/or a misconfiguration.

So, to confirm, you have?

APP_URL=http://admin.digihometour.com
SANCTUM_STATEFUL_DOMAINS=digihometour.com,admin.digihometour.com

Keep in mind that if you're caching the configs on a live server, you may need to clear the cache / do a redeploy /etc for the new values to be considered.

Lastly, you may try the app on your local dev computer, to ensure it's not related to how the live server is setup, re domains, sub domains or something else.

gabrielfigueroa commented 4 years ago

I had it with .test instead of .com since in the instructions provided here it said to replace enso with homedigitour but still kept the .test domain. I am just testing the app on a brand new vps so it should not be an issue as I am installing exactly the services with the corresponding versions needed. I am not sure how device_name is related to SANCTUM_STATEFUL_DOMAINS but I will update the .env files with the correct domain (which I had originally) and run php artisan to clear the cache and try once more.

gabrielfigueroa commented 4 years ago

it worked now. thank you very much!