Support the ongoing development of Laravel.io →
Authentication Security Database
Last updated 1 year ago.
0

create a middleware and add it in the password controller

0

I can't use the default middleware?

<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Support\Facades\Auth;

class Authenticate
{
     /**
      * Handle an incoming request.
      *
      * @param  \Illuminate\Http\Request  $request
      * @param  \Closure  $next
      * @param  string|null  $guard
      * @return mixed
      */
     public function handle($request, Closure $next, $guard = null)
     {
        if (Auth::guard($guard)->guest()) {
            if ($request->ajax() || $request->wantsJson()) {
                return response('Unauthorized.', 401);
            } else {
                 return redirect()->guest('login');
            }
         }
         return $next($request);
     }
 }
Last updated 7 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

reficul reficul Joined 26 Nov 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.