last day (14 days later) » 

2:37 PM
1
Q: Laravel Auth::attempt( ) failing

JavacadabraI am working on a login system using Laravel 4. I can successfully register users but when I try to login using the details - email and password it fails every time and I don't know why. This is my Schema for the users table in the db: Schema::create('users', function($table){ $table-

 
Is the password hashed using laravel in the database already, or just a plaintext representation? You may need to properly seed your table with data first.
 
I've set my debug to true in the app.php file so it should return any errors that might occur. However in this instance I am getting no errors and it would appear that it is not validating the details correctly against the ones in my DB
@drmarvelous the password is hashed: i've added the register action to my question.
 
Try using Auth::validate() instead (it'll return a Bool). Is it validating (this will not attempt to set the cookie)
 
Unfortunately still not validating
 
Can you you post the corresponding row from your database? Feel free to alter the data in the row, just want to make sure it's all there.
Moved to chat
 
2:37 PM
I've posted that row data now for you
 
Let's move to here anyway, as we're pushing the comments a bit too long
 
yes I agree, thanks
 
Can you Auth::attempt with manually input credentials instead of POST data?
 
No I've tried that and it doesn't work either
Which makes me believe that it's either not seeing the user table in db or not validating against the data in this table
 
Are you using the standard User model?
 
2:40 PM
Yes I am
I only created my own HomeController
I am looking at the User model getAuthPassword ( ) I am wondering If I should set it to return something here?
Although surely eloquent will be doing this behind the scenes
 
You shouldn't need to, out of the box this should all work
 
YEs
 
Which file/class is your auth code contained in
 
The Auth code is contained in the HomeController class which Is contained within the controllers directory of the app folder
 
Can you paste your user model?
 
2:44 PM
Into this chat? or into my question
use Illuminate\Auth\UserTrait;
use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableTrait;
use Illuminate\Auth\Reminders\RemindableInterface;

class User extends Eloquent implements UserInterface, RemindableInterface {

use UserTrait, RemindableTrait;

/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'users';

/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = array('password');

public function getAuthIdentifier() {
 
Yeah, so barebones standard
This is a bit of a pickle, because everything you have posted indicates this should be working
 
Yep, so the issue is very strange
I know it's very frustrating!
This is my first build with laravel so I don't really have much experience debugging issues like this
 
Can you rehash the password?
 
Before I call auth::attempt?
 
Did you change your encryption token at any time?
 
2:46 PM
I don't think so, I wasn't even aware such a token existed
 
Also, for password_confirmation you don't need to add a validation line for that
 
I literally just went through a register process
 
confirmed on "password" will work fine
 
oh ok thank you
 
Can you nuke your user row and re-register?
 
2:47 PM
Yep, standby
Ok so row is removed, now going to reregister
Same thing, username: joe@gmail.com and password: Test123
entry is in DB but validation still failing
 
Odd :(
One moment, be right back
 
no problem
 
So, I may have to recommend checking out #laravel on freenode
 
ok I'll take a look at that
Thank you very much for your assistance
 
It would appear that there is nothing wrong with your code
Sorry I couldn't be of more help
 
2:55 PM
no thank you very much
 

last day (14 days later) »