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

Can't get sentinel to work with setModel at runtime (Extending Sentinel) #367

Closed
mdixon18 opened this issue Jun 4, 2017 · 6 comments
Closed
Labels

Comments

@mdixon18
Copy link

mdixon18 commented Jun 4, 2017

I am attempting to use the setModel function in runtime in the latest version of Laravel like this:

Sentinel::getUserRepository()->setModel('App\Client');

Then call methods such as Sentinel::getUser();, However, i am finding that when i do this, its accessing the original 'users' table and not the clients table which is represented when i do Sentinel::getUserRepository().

Its like i can login when i use the setModel function, the authenticate works fine and accesses the clients table, but when i use getUser() or check() even though it says the user repository is App\Client it doesn't work.

I've posted a stackoverflow to show more on this:

https://stackoverflow.com/questions/44348872/laravel-sentinel-setmodel-accessing-the-wrong-table

@brunogaspar
Copy link
Member

Hi

Please let us know some more information so we can try to debug the issue a bit better:

  • What Laravel version?
  • What Sentinel version?
  • When exactly, on your routes file, are you setting the user model?

@mdixon18
Copy link
Author

mdixon18 commented Jun 4, 2017

Hello,

cartalyst/sentinel: 2.0.*
laravel/framework: 5.4.*

I run the call at the top of my routes file, i have also tried it in the AppServiceProvider with the same issue. The authenticate method works beautifully, if i dd() out the response it is perfect and it logs me in with the correct user. Upon redirection it is going back to the other model (User) and picking the user out of the incorrect table even though the routes file has set the model and dding out Sentinel::getUserRepository() gives me the correct model.

So far its getUser() and check() i'm struggling with.

Thanks

@brunogaspar
Copy link
Member

Thanks.

I'll have a look as soon as possible.

@mdixon18
Copy link
Author

mdixon18 commented Jun 6, 2017

Thank you, keep me posted 👍

@mdixon18
Copy link
Author

mdixon18 commented Jun 8, 2017

Any news on this yet?

@brunogaspar
Copy link
Member

Hello

You'll need to also define the model on the persistence repository:

Sentinel::getPersistenceRepository()->setUsersModel('App\Client');

I've updated the wiki to mention this as well.

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

No branches or pull requests

2 participants