cms icon indicating copy to clipboard operation
cms copied to clipboard

After switching to DB users, error if file users still exist

Open edalzell opened this issue 4 years ago • 4 comments

Bug description

I switch users over to the DB, then when you try to access the CP (I think) you get this error: https://github.com/statamic/cms/issues/719#issuecomment-943075400.

Removing the users (and no other changes) makes everything work.

How to reproduce

  1. Have a site with file based users
  2. Switch over to DB users, but leave the file users there
  3. access site/cp

Logs

No response

Versions

Statamic 3.2.16 Pro Laravel 8.64.0 PHP 8.0.11 aryehraber/statamic-captcha 1.5.2 aryehraber/statamic-uuid 2.0.3 doublethreedigital/duplicator 2.0.0 edalzell/forma 1.0 jonassiewertsen/statamic-livewire 2.7.0 statamic/seo-pro 2.3.2 transformstudios/blackbaud dev-main transformstudios/events 2.2.2 transformstudios/front 1.7.1 transformstudios/gated dev-main transformstudios/magic-link dev-main transformstudios/review 3.1 transformstudios/simple dev-main transformstudios/stripe dev-main transformstudios/takeover-redirects dev-main

Installation

Fresh statamic/statamic site via CLI

Additional details

No response

edalzell avatar Oct 15 '21 19:10 edalzell

I can confirm a similar thing happening when you try to run php please stache:clear or other stache commands, the error is as follows:

Call to undefined method Statamic\Auth\Eloquent\User::initialPath()

  at vendor/statamic/cms/src/Stache/Stores/UsersStore.php:39

..as with the original report, I am getting this on a site that I switched over from file-based users to database-based users. Deleting the file-based user's yaml files stops the error from appearing.

joseph-d avatar Nov 18 '21 14:11 joseph-d

This line worked for me:

Deleting the file-based user's yaml files stops the error from appearing

sineld avatar May 21 '22 11:05 sineld

I think the issue may be with the docs on this... on this page it says "In config/statamic/stache.php, comment out the users store."

That means the stache config still has a users key as it gets it from core... really what you need to do is set directory in the users key to null, and then these commands work fine.

ryanmitchell avatar May 26 '22 08:05 ryanmitchell

I also had this problem when switching from file-based users to database.

The line in the documentation "In config/statamic/stache.php, comment out the users store" was confusing because the stores array in my config/statamic/stache.php file is empty.

However, I can confirm that deleting any remaining yaml files for each user does stop the Call to undefined method Statamic\Auth\Eloquent\User::initialPath() error from happening.

mattkibbler avatar Jun 10 '22 09:06 mattkibbler

Adding this method to User model solves issue for me:

public function isSuper()
{
    return $this->super;
}

sineld avatar Oct 31 '22 19:10 sineld