0
我正在开发一段时间的网站。我总是使用Laravel Auth::attempt
进行身份验证,之前它运行良好,但现在它不起作用。我刚刚从PHPMyAdmin中删除了我的数据库并迁移了所有的迁移。此后Auth::attempt
和Hash::check
总是返回false。Laravel 5.0 Hash :: check和Auth :: Attempt总是返回false
这是我DevelopmentSeeder:
\App\Models\Employee\UserAccount::create([
'AccountName' => 'admin',
'Username' => 'superadmin',
'Password' => \Illuminate\Support\Facades\Hash::make('hello'),
'UserType' => 'Super Admin'
]);
我在我的控制器试过这样:
$acc = UserAccount::where('AccountName', '=', 'admin')
->where('Username', '=', 'superadmin')
->where('IsActive', '=', 1)->get();
if(count($acc) > 0){
dd(Hash::check('hello', $acc[0]->Password));
}
模具转储始终返回false。我已经尝试过Auth::attempt
,但它也会返回false。
这是我的UserAccount型号:
use Illuminate\Database\Eloquent\Model;
use Illuminate\Auth\Authenticatable;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
class UserAccount extends Model implements AuthenticatableContract, CanResetPasswordContract {
use Authenticatable, CanResetPassword;
protected $table = "UserAccounts";
protected $fillable = ['AccountName', 'EmployeeID', 'Username', 'Password', 'Email', 'UserType'];
protected $hidden = ['Password', 'remember_token'];
public function getAuthIdentifier(){
return $this->getKey();
}
public function getAuthPassword(){
return $this->Password;
}
public function getRememberToken(){
return $this->remember_token;
}
public function setRememberToken($value){
$this->remember_token = $value;
}
public function getRememberTokenName(){
return 'remember_token';
}
public function setPasswordAttribute($password){
$this->attributes['Password'] = bcrypt($password);
}
public function getEmailForPasswordReset(){
return $this->Email;
}
}