Я уже некоторое время пытаюсь обмотать голову вокруг этого, но не могу понять, в чем проблема. Я вручную создал страницу входа в Laravel 5.2. *, Которую я успешно сделал в прошлом, но по какой-то причине на этот раз он не работает ... Вот разбивка важных частей моего кода:postLogin, отображающий токен и, похоже, не вызывается в Laravel 5.2
Route::group(['middleware' => ['web']], function() {
// Authentication Routes...
Route::get('auth/login', 'Auth\[email protected]');
Route::post('auth/login', 'Auth\[email protected]');
Route::get('auth/logout', 'Auth\[email protected]');
....
});
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="csrf-token" content="{{ csrf_token() }}" />
....
</head>
<body>
<form action="{{ url('/auth/login') }}" class="clearfix" id="login" method="post" novalidate>
{!! csrf_field() !!}
@if (count($errors) > 0)
<div class="show validation-summary">
<strong>Whoops!</strong> There were some problems with your input.<br />
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@else
<div class="validation-summary">
<ul>
</ul>
</div>
@endif
<label class="grey" for="email"><b>Username: </b></label>
<input class="field" type="text" name="email" id="email" value="{{ old('email') }}" size="23" />
<label class="grey" for="password"><b>Password:</b></label>
<input class="field" type="password" name="password" id="password" size="23" />
<button class="bt_login" name="submit" type="submit">
<i class="fa fa-btn fa-sign-in"></i> Login
</button>
</form>
....
</body>
</html>
Вот метод postLogin от признака AuthenticatesUsers:
public function postLogin(Request $request)
{
return $this->login($request);
}
public function login(Request $request)
{
$this->validate($request, [
$this->loginUsername() => 'required', 'password' => 'required',
]);
// If the class is using the ThrottlesLogins trait, we can automatically throttle
// the login attempts for this application. We'll key this by the username and
// the IP address of the client making these requests into this application.
$throttles = $this->isUsingThrottlesLoginsTrait();
if ($throttles && $this->hasTooManyLoginAttempts($request)) {
return $this->sendLockoutResponse($request);
}
$credentials = $this->getCredentials($request);
if (Auth::guard($this->getGuard())->attempt($credentials, $request->has('remember'))) {
return $this->handleUserWasAuthenticated($request, $throttles);
}
// If the login attempt was unsuccessful we will increment the number of attempts
// to login and redirect the user back to the login form. Of course, when this
// user surpasses their maximum number of attempts they will get locked out.
if ($throttles) {
$this->incrementLoginAttempts($request);
}
return $this->sendFailedLoginResponse($request);
}
При нажатии на кнопку входа, кажется, чтобы отобразить значение маркера CSRF и даже не ударил метод postLogin в черте AuthenticatesUsers. Если вам нужен живой пример, вы можете перейти на http://www.dorothea.co.za/auth/login и щелкнуть по скользящей панели Log In в верхней части экрана, а затем щелкнуть по имени пользователя.
Можете ли вы опубликовать свой метод 'Auth \ AuthController @ postLogin'/ – jaysingkar
@jaysingkar мой метод postLogin - это только значение по умолчанию из атрибута AuthenticatesUsers, я обновлю сообщение, чтобы включить эту информацию. –
Вы уверены, что не забыли какое-то эхо для отладки где-то? Это действительно странно, он не может просто вывести токен и умереть. – TheFallen