身份验证laravel 4.2无法正常工作

时间:2015-02-25 12:17:13

标签: php authentication laravel laravel-4

身份验证laravel无法处理我的程序。我用谷歌搜索但没有解决这个问题。我的节目是

的LoginController @ AUTH

public function auth()
{
    $username = Input::get('username');
    $password = Input::get('pass');
    if(Auth::attempt(array('id' => $username, 'password' => $password))) 
    {
        echo "Work";
    }
    else 
    {
        echo "Bad";
    }
}

Authtable.php

<?php

use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableInterface;

class Authtable extends Eloquent implements UserInterface, RemindableInterface 
{

protected $table = 'authtable';

protected $hidden = array('password');

/**
 * Get the unique identifier for the user.
 *
 * @return mixed
 */
public function getAuthIdentifier()
{
    return $this->getKey();
}

/**
 * Get the password for the user.
 *
 * @return string
 */
public function getAuthPassword()
{
    return $this->password;
}

/**
 * Get the e-mail address where password reminders are sent.
 *
 * @return string
 */
public function getReminderEmail()
{
    return $this->email;
}

public function getRememberToken()
{
    return $this->remember_token;
}

public function setRememberToken($value)
{
    $this->remember_token = $value;
}

public function getRememberTokenName()
{
    return 'remember_token';
}

}

auth.php

'driver' => 'eloquent',
'model' => 'Authtable',
'table' => 'authtable',

和nullable remember_token(varchar(100)),密码(varchar(60))但仍然不起作用。请给出一些解决方案。

1 个答案:

答案 0 :(得分:0)

我对此感到很糟糕。

  • Composer dump-autoload以确保模型名称正常运行。
  • 检查型号名称是否没有冲突
  • 检查'authtable'列名称。这些列是否包含您输入的内容?'id' => $username, 'password' => $password
相关问题