我正在laravel 5电子商务门户网站上工作。Laravel 5密码重置不起作用
我遇到问题,当用户使用现成的脚本更新密码。
问题是我可以完全发送链接给客户,没有任何问题,客户也可以更改他的密码。但是,当注销并重新登录时,我得到的错误为Invalid credentials
。
在我的routes.php文件,我有这样的:
Route::controllers([
'auth' => 'Auth\AuthController',
'password' => 'Auth\PasswordController',
]);
这是登录页面:
<form class="form-horizontal" role="form" method="POST" action="{{ url('/login') }}">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<div class="form-group">
<label class="col-md-4 control-label">E-Mail Address</label>
<div class="col-md-6">
<input type="email" class="form-control" name="email" value="{{ old('email') }}">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Password</label>
<div class="col-md-6">
<input type="password" class="form-control" name="password">
</div>
</div>
<div class="form-group">
<div class="col-md-4"></div>
<div class="col-md-4">
<a href="{{url('/password/email')}}">Forgot Password</a>
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<button type="submit" class="btn btn-primary btn-block">Login</button>
</div>
</div>
</form>
我登出后,一旦密码已重置我无法再次登录。
EDIT 1:
当点击登录表单页面上的登录按钮时,postLogin
方法被调用。下面的代码
public function postLogin(Request $request) {
$this->validate($request, [
'email' => ['required', 'exists:users,email,role,customer'],
'password' => 'required'
]);
$credentials = $request->only('email', 'password');
if (\Auth::attempt($credentials)) {
\Session::flash('logged_in', 'You have successfully logged in.');
return redirect('/');
}
return redirect('/login')->withInput($request->all())->withErrors(['email' => 'Invalid Email Address Or Password']);
}
编辑2:
我只是意识到,登录不检查哈希,因此返回false
,做dd(\Hash::check($request->password, $user->password))
,在更新密码,重新登录后什么可能是这个问题?
我哪里犯错了?请引导我。
在此先感谢。
P.S.:我使用的默认只是更新密码,全部休息,我已经使控制器和模型都工作正常没有任何问题。
在哪里以及如何检查? –
从数据库中取出用户对象,使用Eloquent User :: find($ id)并从那里获取密码哈希$ user-> password –
请看看更新后的问题。 –