目前,当用户登录我的 Laravel 应用程序时,我使用以下规则......
// Validation rules
$rules = array(
'email' => 'required|email|exists:users,email',
'password' => 'required'
);
我正在寻找的是用于检查用户密码的验证规则。
目前,当用户登录我的 Laravel 应用程序时,我使用以下规则......
// Validation rules
$rules = array(
'email' => 'required|email|exists:users,email',
'password' => 'required'
);
我正在寻找的是用于检查用户密码的验证规则。
来自文档:
if (Auth::attempt(array('email' => $email, 'password' => $password))) {
return Redirect::intended('dashboard');
}
例子:
$userdata = array(
'email' => Input::get('email'),
'password' => Input::get('password')
);
$rules = array(
'email' => 'required|email|exists:users,email',
'password' => 'required'
);
// Validate the inputs.
$validator = Validator::make($userdata, $rules);
// Check if the form validates with success.
if ($validator->passes()) {
// Try to log the user in.
if (Auth::attempt($userdata)) {
// Redirect to homepage
return Redirect::to('')->with('success', 'You have logged in successfully');
} else {
// Redirect to the login page.
return Redirect::to('login')->withErrors(array('password' => 'Password invalid'))->withInput(Input::except('password'));
}
}