我的app.php
/*
|--------------------------------------------------------------------------
| Default Authentication Driver
|--------------------------------------------------------------------------
|
| This option controls the authentication driver that will be utilized.
| This driver manages the retrieval and authentication of the users
| attempting to get access to protected areas of your application.
|
| Supported: "database", "eloquent"
|
*/
'driver' => 'database',
/*
|--------------------------------------------------------------------------
| Authentication Model
|--------------------------------------------------------------------------
|
| When using the "Eloquent" authentication driver, we need to know which
| Eloquent model should be used to retrieve your users. Of course, it
| is often just the "User" model but you may use whatever you like.
|
*/
'model' => 'App\Model\Member',
/*
|--------------------------------------------------------------------------
| Authentication Table
|--------------------------------------------------------------------------
|
| When using the "Database" authentication driver, we need to know which
| table should be used to retrieve your users. We have chosen a basic
| default value but you may easily change it to any table you like.
|
*/
'table' => 'members',
我的模特:
类成员扩展Model实现Authenticatable {
protected $fillable = [];
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'members';
protected $primaryKey = 'id';
/**
* 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 token value for the "remember me" session.
*
* @return string
*/
public function getRememberToken()
{
// TODO: Implement getRememberToken() method.
}
/**
* Set the token value for the "remember me" session.
*
* @param string $value
* @return void
*/
public function setRememberToken($value)
{
// TODO: Implement setRememberToken() method.
}
/**
* Get the column name for the "remember me" token.
*
* @return string
*/
public function getRememberTokenName()
{
// TODO: Implement getRememberTokenName() method.
}
}
尝试Auth:尝试(....
if (Auth::attempt(array('email' => Request::input('email'), 'password' => Request::input('password'))))
{
echo ("SUCCESS");
Auth::logout();
}
else
{
echo ("FAILED");
}
这总是“失败”。如果我进行Member::where....
搜索,我将正确获取记录,因此我知道模型和数据库是可以的。
为什么Auth ::尝试失败?我确保电子邮件和密码正确并存在于数据库中。
答案 0 :(得分:0)
Auth::attempt()
要求使用Hash::make($password)
或bcrypt($password)
对数据库中存储的密码进行哈希处理。