Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrading to Sentinel 3.0 breaks support for UUID as primary key #536

Open
dantarian opened this issue Jul 24, 2020 · 3 comments
Open

Upgrading to Sentinel 3.0 breaks support for UUID as primary key #536

dantarian opened this issue Jul 24, 2020 · 3 comments

Comments

@dantarian
Copy link

Your Environment

  • OS and Version: Debian Buster
  • PHP Version: 7.4.0
  • Sentinel Version: 3.0.4

Background

We are in the processing of upgrading an existing application from Laravel 5.8 to Laravel 6.0, and in the process have upgraded Sentinel from 2.0 to 3.0. Our user model uses a UUID, handled as a string, as its primary key.

Expected behaviour

Sentinel::findById() should accept a string ID.

Actual behaviour

The following error is thrown:

Symfony\Component\Debug\Exception\FatalThrowableError thrown with message "Argument 1 passed to Cartalyst\Sentinel\Users\IlluminateUserRepository::findById() must be of the type int, string given"

Steps to reproduce

As above.

I can see that Sentinel 3.0 introduced type-hinting in a number of places which seems to be the root cause of this issue, and I can see that there's an outstanding PR #529 that is related to this. Is there any plan to support UUIDs in future? Is there a way to work around this issue short of forking the repo and removing the type hints?

@WildanHarits
Copy link

Same with me :(
come here for future solution

@mar846
Copy link

mar846 commented Jun 9, 2022

hi, want to follow up, so what solution did you guys did to fix this? @WildanHarits @dantarian
i wanted to use uuid as well

@WildanHarits
Copy link

WildanHarits commented Jun 10, 2022

for quick fix, this work

change
vendor/cartalyst/sentinel/src/users/eloquentUser

public function getUserId(): int { return $this->getKey(); }

to

public function getUserId(): string { return $this->getKey(); }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants