I try to catch error message from validate in .../app/Http/Controllers/Auth/ResetPasswordController.php
:
public function reset(Request $request)
{
$this->validate($request, $this->rules(), $this->validationErrorMessages());
$response = $this->broker()->reset(
$this->credentials($request), function ($user, $password) {
$this->resetPassword($user, $password);
}
);
return $response == Password::PASSWORD_RESET
? $this->sendResetResponse($response)
: $this->sendResetFailedResponse($request, $response);
}
but if the validate failed in session there is no errors.
In:
public function validate(Request $request, array $rules, array $messages = [], array $customAttributes = [])
{
$validator = $this->getValidationFactory()->make($request->all(), $rules, $messages, $customAttributes);
if ($validator->fails()) {
$this->throwValidationException($request, $validator);
}
}
throw exception but I do not know how to use it in session.
But if I check $validator->errors()->getMessages()
in protected function formatValidationErrors(Validator $validator)
error message exists:
array:1 [▼
"password" => array:1 [▼
0 => "The password confirmation does not match."
]
]
EDITED
In my case problem was multiple use StartSession
in Kernel.php
. After commented StartSession
in $middleware
flash in session works good. I do not know how and when it may happend. From this:
protected $middleware = [
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
\Illuminate\Session\Middleware\StartSession::class,
\App\Http\Middleware\LanguageSwitcher::class,
];
to this:
protected $middleware = [
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
//\Illuminate\Session\Middleware\StartSession::class,
\App\Http\Middleware\LanguageSwitcher::class,
];
and
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
(...)
via Tomasz