Laravel
0
Вклад в тег
php artisan make:middleware RequirePassword
…
protected $routeMiddleware = [
…
'password.confirm' => \App\Http\Middleware\RequirePassword::class,
…
];
…
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Auth\Middleware\RequirePassword as RequirePasswords;
class RequirePassword extends RequirePasswords
{
public function handle($request, Closure $next, $redirectToRoute = null)
{
if ($this->shouldConfirmPassword($request)) {
if ($request->expectsJson()) {
return $this->responseFactory->json([
'message' => 'Password confirmation required.',
], 423);
}
return $this->responseFactory->redirectGuest(
$this->urlGenerator->route($redirectToRoute ?? 'password.confirm', app()->getLocale())
);
}
return $next($request);
}
}