基本Laravel 5.4请求验证不起作用

时间:2017-10-03 11:08:37

标签: php laravel validation request laravel-5.4

我的问题是,验证方法没有验证,我的应用程序中的任何验证请求都存在同样的问题。有什么建议吗?!

这是AuthenticatesUsers的一部分:

namespace Illuminate\Foundation\Auth;

use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth;

trait AuthenticatesUsers {

public function login(Request $request) {
$this->validateLogin($request);

if ($this->hasTooManyLoginAttempts($request)) {
    $this->fireLockoutEvent($request);

    return $this->sendLockoutResponse($request);
}

if ($this->attemptLogin($request)) {
    return $this->sendLoginResponse($request);
}
$this->incrementLoginAttempts($request);

return $this->sendFailedLoginResponse($request);
}

protected function validateLogin(Request $request) {
$this->validate($request, [
    $this->username() => 'required|string',
    'password' => 'required|string',
]);
}

protected function attemptLogin(Request $request) {
return $this->guard()->attempt(
                $this->credentials($request), $request->has('remember')
);
}

protected function credentials(Request $request) {
return $request->only($this->username(), 'password');
}

protected function sendFailedLoginResponse(Request $request) {
$errors = [$this->username() => trans('auth.failed')];

if ($request->expectsJson()) {
    return response()->json($errors, 422);
}

return redirect()->back()
                ->withInput($request->only($this->username(), 'remember'))
                ->withErrors($errors);
}

public function username() {
return 'email';
}

protected function guard() {
return Auth::guard();
}
}

0 个答案:

没有答案