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;
}
}