php - Laravel 5 built in User Authentication -


i trying use laravel 5 built in user authentication.in regard redirect user route/page/controller after logged in. trying change code of complied.php file. trying change /home of below code, not working.

trait authenticatesandregistersusers     {         protected $auth;         protected $registrar;         public function getregister()         {             return view('auth.register');         }         public function postregister(request $request)         {             $validator = $this->registrar->validator($request->all());             if ($validator->fails()) {                 $this->throwvalidationexception($request, $validator);             }             $this->auth->login($this->registrar->create($request->all()));             return redirect($this->redirectpath());         }         public function getlogin()         {             return view('auth.login');         }         public function postlogin(request $request)         {             $this->validate($request, array('email' => 'required|email', 'password' => 'required'));             $credentials = $request->only('email', 'password');             if ($this->auth->attempt($credentials, $request->has('remember'))) {                 return redirect()->intended($this->redirectpath());             }             return redirect($this->loginpath())->withinput($request->only('email', 'remember'))->witherrors(array('email' => $this->getfailedloginmessage()));         }         protected function getfailedloginmessage()         {             return 'these credentials not match our records.';         }         public function getlogout()         {             $this->auth->logout();             return redirect('/home');         }         public function redirectpath()         {             if (property_exists($this, 'redirectpath'))              {                 return $this->redirectpath;             }             return property_exists($this, 'redirectto') ? $this->redirectto : '/home';         }         public function loginpath()         {             return property_exists($this, 'loginpath') ? $this->loginpath : '/auth/login';         }     } 

thanks

you not supposed change in compiled.php

in redirectifauthenticated middleware change,

return new redirectresponse(url('/home')); 

to

return new redirectresponse(url('/')); 

this redirects logged in user desired path, once logged in user returns website. so,handle function lookes below,

public function handle($request, closure $next) {      if ($this->auth->check())     {         return new redirectresponse(url('/'));     }      return $next($request); } 

after add following in authcontroller

public $redirectto = '/'; public $redirectafterlogout = '/'; 

so after successful login user wil redirected redirectto , after logout user redirected redirectafterlogout.


Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -