Validate password on reset according to rules (#158)
* move password rules to Models\User::PASSWORD_RULES * validate new password according to rules on password reset * add password requirements info to auth.passwords.reset view
This commit is contained in:
parent
9d69f47ade
commit
e65dc5708d
|
@ -31,4 +31,12 @@ class ResetPasswordController extends Controller
|
||||||
{
|
{
|
||||||
$this->middleware('guest');
|
$this->middleware('guest');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected function rules() {
|
||||||
|
return [
|
||||||
|
'token' => 'required', 'email' => 'required|email',
|
||||||
|
'password' => 'required|confirmed|' . User::PASSWORD_RULES,
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,7 @@ class AccountController extends Controller
|
||||||
|
|
||||||
$this->validate($request, [
|
$this->validate($request, [
|
||||||
'current_password' => 'required',
|
'current_password' => 'required',
|
||||||
'new_password' => 'required|confirmed|different:current_password|regex:((?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,})',
|
'new_password' => 'required|confirmed|different:current_password|' . Models\User::PASSWORD_RULES,
|
||||||
'new_password_confirmation' => 'required'
|
'new_password_confirmation' => 'required'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
|
@ -76,6 +76,13 @@ class User extends Model implements AuthenticatableContract,
|
||||||
*/
|
*/
|
||||||
protected $hidden = ['password', 'remember_token', 'totp_secret'];
|
protected $hidden = ['password', 'remember_token', 'totp_secret'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The rules for user passwords
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
const PASSWORD_RULES = 'min:8|regex:((?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,})';
|
||||||
|
|
||||||
public function permissions()
|
public function permissions()
|
||||||
{
|
{
|
||||||
return $this->hasMany(Permission::class);
|
return $this->hasMany(Permission::class);
|
||||||
|
|
|
@ -55,6 +55,7 @@
|
||||||
<strong>{{ $errors->first('password') }}</strong>
|
<strong>{{ $errors->first('password') }}</strong>
|
||||||
</span>
|
</span>
|
||||||
@endif
|
@endif
|
||||||
|
<p class="text-muted"><small>{{ trans('base.password_req') }}</small></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|
Loading…
Reference in New Issue