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

How do I get Sentinel to authenticate checking additional fields? #554

Closed
adam-jones-net opened this issue Mar 24, 2021 · 2 comments
Closed

Comments

@adam-jones-net
Copy link

I have added an additional criteria to the authenticate() call in Sentinel as I have a column in my users table called 'enabled'. That needs to be set to 1 for a user to login. My authentication request to Sentinel is as follows:

if (Sentinel::authenticate(['username'=> $request->log, 'password' => $request->pwd, 'enabled' => 1],$rememberMe)){

however even for users where the record is set to 0, the authentication still passes. It seems that this enabled field is just ignored completely.

What am I doing wrong ?

@brunogaspar
Copy link
Member

Hi

You can achieve this by Extending Sentinel, more specifically, the User model.

Then on the extended User model, you need to add a protected $loginNames = ['email', 'enabled']; property, which be default only contains the email field.

Hope it helps.

@adam-jones-net
Copy link
Author

Thanks so much @brunogaspar , that did the trick!

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

2 participants