youssefboudaya's avatar

How to redirect after login in laravel 4.2?

I'm used to working on laravel 5.4 and above, i just got this project with a problem in authentification that is rather weird. Locally, the authentification works just fine but when i try to log using the project on prod i always get redirected to login page. this is the login function:

public function loginadmin()
{
    $pseudo = Input::get('pseudo');
    $pass = Input::get('pass');

    $user = Admin::where('pseudo',$pseudo)->where('pass',$pass)->get()->first();
    if($user){
      Auth::admin()->loginUsingId( $user->id );
      return Redirect::back();
    }
    else{
      Session::flash('errorAuth', "ok");
      return Redirect::back();
    }
}

this is the routes.php

 /* Connexion */
Route::get('admin-igd', function(){ 
  if( !Auth::admin()->get())
    return View::make('admin.login');
    
  return Redirect::to('admin-igd/slider');
});

and this is the filters.php:

 Route::filter('loginadmin', function($route, $request)
 {
if ( !Auth::admin()->get()) {
    return Redirect::to('admin-igd');
}
 });
0 likes
5 replies
munazzil's avatar

Check your Logincontroller and change as like below,

         protected $redirectTo = '/home';
munazzil's avatar

Have you used any middleware in your controller function?

tykus's avatar

Are passwords really stored in plain text????

$pass = Input::get('pass');

Admin::where('pseudo',$pseudo)->where('pass',$pass)->get()->first();

@munazzil middleware did not exist in Laravel 4.2, there are filters which are approximately equivalent. There is a built-in auth filter which should perform the same functionality as the loginadmin admin filter.

2 likes
munazzil's avatar

Thank you @tykus I don't even have any idea about 4.X version configuration and operation.

Please or to participate in this conversation.