11 months ago

Manual Login

Posted 11 months ago by Atef95

Hey Guys I'm trying to make a manual login in my application so I created a middleware to protect some routes from unauthorized user when I login it always redirects me back to the same page ..

I created isAuth middleware


namespace App\Http\Middleware;

use Closure;
use Auth;

class isAuth
     * Handle an incoming request.
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
    public function handle($request, Closure $next)
        if (Auth::check()){
        return $next($request); }
           return redirect()->route('showLogin');

I have the login function below

      public function handleLogin(Request $request)
        if (Auth::attempt(['email' => $request->email, 'password' => $request->password])) {
            if (Auth::check()) {

                alert()->success('Succés!', 'Bienvenue!');
                return redirect()->route('showHome');
            } else {
                alert()->error('Oups!', 'Email ou Mot de passe incorrect !');
                return redirect()->back();



this is Home Page route ( redirection after login)

Route::group(['module' => 'General', 'middleware' => ['isAuth'], 'namespace' => 'App\Modules\General\Controllers'], function() {

Route::get('/','[email protected]')->name('showHome');

Please sign in or create an account to participate in this conversation.