1

Laravel 5.1 Sentinel 2

Here is my logout() in controller:

public function logout()
    {
        $user = Sentinel::getUser();
        Sentinel::logout($user, true);
        return redirect('/shopadmin/login');
    }

Here is how I login:

public function login(Request $request)
    {
        if (Sentinel::guest()):
            $email = $request->get('email');
            $pass = $request->get('password');
            $credentials = [
                'email'    => $email,
                'password' => $pass,
            ];
            // $role = Sentinel::findRoleByName('admin');
            $user = Sentinel::findById(1);


            $user = Sentinel::findUserById(1);
            if($user = Sentinel::authenticateAndRemember($user, $credentials)):
                return redirect('/shopadmin');
            else:

                return view('backend.login');
            endif;

        else:
            return redirect('/shopadmin');
        endif;
    }

And I also have this in my __contruct

public function __construct()
{
    $this->layout = view('layouts.backend');
    $user = Sentinel::check();
    view()->share('user',$user);

}

No middleware

My problem is after logout runs, user should get redirected to login page, but instead it forwards me to the dashboard and Sentinel::getUser(); still shows active user.

with following: **#persistableKey: "user_id"

#persistableRelationship: "persistences"**

Is there a different way to log out? I cannon flush entire session because I am keeping some non-user variables.

Technically, logout() should destroy all cookies and sessions related to user? correct? Then why in the Functional-Uniformly-Coded-Kernel my user is still logged in?!

Thanks for help!

TrueStory
  • 439
  • 5
  • 17

0 Answers0