Check your "users" table - it should contain "remember_token" (varchar type) column, if it doesn't you have to create it manually.
Aug 12, 2014
18
Level 8
Auth::attempt fails
I'm having problems with my project, it won't log any users in with the Auth::attempt() - it just does nothing - no error message or anything is displayed.
I really don't know what the problem is, been trying to figure it out for a while now.
This is my form
{{Form::open(array('action' => 'SessionsController@store', 'class' => 'login', 'method' => 'POST'))}}
{{Form::text('email', null, ['class' => 'form', 'required' => 'required', 'placeholder' => 'Email'])}}
{{Form::password('password', ['class' => 'form', 'required' => 'required', 'placeholder' => 'Šifra'])}}
{{Form::submit('Prijava', array('class' => 'form', 'style' => 'text-align:center;'))}}
{{Form::close()}}
This is my User model
<?php
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';
protected $fillable = ['fname', 'lname', 'code', 'dob', 'email', 'gender', 'username', 'password', 'confirmpassword', 'city'];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = array('password', 'remember_token');
public function getRememberToken()
{
return $this->remember_token;
}
public function setRememberToken($value)
{
$this->remember_token = $value;
}
public function getRememberTokenName()
{
return 'remember_token';
}
public function getAuthIdentifier() {
return $this->getKey();
}
public function getAuthPassword() {
return $this->password;
}
}
And this is my SessionsController
class SessionsController extends \BaseController {
public function store()
{
$input = Input::only('email', 'password');
if (Auth::attempt($input))
{
return 'Success';
}
}
}
Please or to participate in this conversation.