T
T
tol642020-01-24 16:51:10
Laravel
tol64, 2020-01-24 16:51:10

How to override the handle method in the RequirePassword middleware?

Greetings.
Please tell me how to override the RequirePassword::handle () method from the vendor in custom classes ( vendor\laravel\framework\src\Illuminate\Auth\Middleware\RequirePassword.php ):

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')
            );
        }
        return $next($request);
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2020-01-24
@tol64

Create your own intermediary in the application, which will be inherited from the vendor one and override the method in it. And connect your own intermediary

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question