Can't login to cp when setting statamic guard for cp users
Bug description
I move it here, as it seems to happen to more users.
The login box does nohing when trying to login. The password check seems to happen, as the login box only trembles with a wrong password. With a correct password, the page refreshes and nothing happens.
Have followed the steps here: https://statamic.dev/tips/using-an-independent-authentication-guard Also explained here: https://statamic.com/forum/4942-existing-app-with-solo-user-but-multiple-users-in-db
The pro is enabled.
When creating the ser directly using the yaml file, the password gets encrypted and a user id is generated correctly, but can't still login.
No errors into the logs at all.
Thanks : )
How to reproduce
Install statamic on an existing laravel 8 app and configure statamic guard for cp users.
config/statamic/users.php
'repository' => 'file',
'repositories' => [
'file' => [
'driver' => 'file',
'paths' => [
'users' => base_path('users'),
'roles' => resource_path('users/roles.yaml'),
'groups' => resource_path('users/groups.yaml'),
],
],
'eloquent' => [
'driver' => 'eloquent',
],
],
/* .. */.
'guards' => [
'cp' => 'statamic',
'web' => 'web',
],
config/auth.php
'guards' => [
'api' => [
'driver' => 'passport',
'provider' => 'users',
],
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'statamic' => [
'driver' => 'session',
'provider' => 'statamic',
]
],
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\Models\User::class,
],
'statamic' => [
'driver' => 'statamic',
],
],
config/statamic/stache.php
'stores' => [
/* ... */
'users' => [
'class' => Stores\UsersStore::class,
'directory' => base_path('users'),
],
]
Logs
No response
Versions
Laravel 8 Latest statamic 3 version
Installation
Existing Laravel app
Additional details
No response
Can you provide a repo with this problem reproduced so we can investigate?
Can you provide a repo with this problem reproduced so we can investigate?
Yes; just a laravel + livewire fresh install + statamic, with the statamic guard
I had similar trouble with a Fresh Statamic install with statamic-cli. I followed this guide exactly: https://statamic.dev/tips/using-an-independent-authentication-guard
The first problem was that my password was hashed and saved incorrectly during the cli installation. That might be a windows issue as the prompt says 'Password (Your input will be hidden)' when in fact the input was visible. Anyway, my password was saved incorrectly in the yaml file so I manually copied the hash value from another project to fix it.
The second thing I had to do was run
php artisan config:clear
because my password reset form kept looking in the eloquent database.
Also, I noticed another thing. Your config above shows:
'guards' => [
'cp' => 'statamic',
'web' => 'web',
],
When this guide says it should be:
'guards' => [
'cp' => 'statamic',
'web' => 'statamic',
],
You might have a different issue but maybe this will help.
Any updates on this? Having the same issue with Laravel 10 and Statamic 4
@nickashley there are some updated docs being worked on - https://github.com/statamic/docs/pull/1139 - maybe check those out to make sure you've covered everything.
This issue is relatively old now and I'm not able to reproduce this on a fresh site.
We've recently updated our docs around configuring independent auth guards, which adds some more clarity to some steps in the process.
I'm going to close this issue now. If anyone's still having issues, please open a new issue and we can take a look.