rinvex / laravel-auth

A powerful authentication, authorization and verification package built on top of Laravel. It provides developers with Role Based Access Control, Two-Factor Authentication, Social Authentication, and much more, compatible Laravel’s standard API and fully featured out of the box.
https://rinvex.com
MIT License
132 stars 12 forks source link

Unknown column 'username' or goes to register view trying to login #28

Closed emahuni closed 8 years ago

emahuni commented 8 years ago

Error

QueryException in Connection.php line 761:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'username' in 'where clause' (SQL: select * from `users` where `username` = emahuni limit 1)

that happens when trying to log in using username, if email is used then it goes to registration page.

emahuni commented 8 years ago

I did the migrations properly, in fact I rolled back everything, then migrated. This is after I registered the user emahuni and verified by tweaking in DB manually (which worked before I updated). Please note, it is trying to use the table users not rinvex_fort_users.

emahuni commented 8 years ago

Hi. I tested updated, and totally resetted everything related to Rinvex to start afresh and this happened again:


QueryException in Connection.php line 761:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'username' in 'where clause' (SQL: select * from `users` where `username` = emahuni limit 1)
in Connection.php line 761
at Connection->runQueryCallback('select * from `users` where `username` = ? limit 1', array('emahuni'), object(Closure)) in Connection.php line 717
at Connection->run('select * from `users` where `username` = ? limit 1', array('emahuni'), object(Closure)) in Connection.php line 351
at Connection->select('select * from `users` where `username` = ? limit 1', array('emahuni'), true) in Builder.php line 1648
at Builder->runSelect() in Builder.php line 1634
at Builder->get(array('*')) in Builder.php line 613
at Builder->getModels(array('*')) in Builder.php line 318
at Builder->get(array('*')) in Builder.php line 288
at Builder->first() in EloquentUserProvider.php line 104
at EloquentUserProvider->retrieveByCredentials(array('username' => 'emahuni', 'password' => '1a2b3c4d5e6f')) in SessionGuard.php line 355
at SessionGuard->attempt(array('username' => 'emahuni', 'password' => '1a2b3c4d5e6f'), false) in AuthenticationController.php line 71
at AuthenticationController->processLogin(object(UserAuthenticationRequest))
at call_user_func_array(array(object(AuthenticationController), 'processLogin'), array(object(UserAuthenticationRequest))) in Controller.php line 55
at Controller->callAction('processLogin', array(object(UserAuthenticationRequest))) in ControllerDispatcher.php line 44
at ControllerDispatcher->dispatch(object(Route), object(AuthenticationController), 'processLogin') in Route.php line 189
emahuni commented 8 years ago

I trimmed the log, it's longer, but I think the problem is starting at AuthenticationController@processLogin. It is passing credentials retrieval to EloquentUserProvider

at SessionGuard->attempt(array('username' => 'emahuni', 'password' => '1a2b3c4d5e6f'), false) in AuthenticationController.php line 71
at AuthenticationController->processLogin(object(UserAuthenticationRequest))

, which is passing to the Laravel user retrieval system (SessionGuard) that uses the users DB table of course.

EloquentUserProvider->retrieveByCredentials(array('username' => 'emahuni', 'password' => '1a2b3c4d5e6f')) in SessionGuard.php line 355

The DB builder:

at Builder->runSelect() in Builder.php line 1634
at Builder->get(array('*')) in Builder.php line 613
at Builder->getModels(array('*')) in Builder.php line 318
at Builder->get(array('*')) in Builder.php line 288
at Builder->first() in EloquentUserProvider.php line 104

is creating that query which is obviously wrong:

at Connection->runQueryCallback('select * from `users` where `username` = ? limit 1', array('emahuni'), object(Closure)) in Connection.php line 717
at Connection->run('select * from `users` where `username` = ? limit 1', array('emahuni'), object(Closure)) in Connection.php line 351
at Connection->select('select * from `users` where `username` = ? limit 1', array('emahuni'), true) in Builder.php line 1648

and causing that error.

emahuni commented 8 years ago

I am not sure what changed in the code to cause this problem that wasn't there on earlier versions... just look around that a bit I am sure we can figure it out...

Then there is the register view if you use email to log in... I think it's doing that because it would've passed through the query without errors (email field exists in users table), but with no effect since it is not the intended behavior. Then Rinvex redirects to register view...

Therefore fixing that above issue should also take care of that registration view issue.

Again, this may be related to installation configuration Please update the readme.md file as soon as possible if the required installation configuration is now different.

Omranic commented 8 years ago

We're trying to make the installation as smooth as we can, and mostly automated without manual updates, and for such purpose we've updated the package now to automatically override default session guard & user provider without the need to change any configurations. Check again & it should work like a charm 😄 66f1379