sentinel icon indicating copy to clipboard operation
sentinel copied to clipboard

user object returned on login logout

Open shahidbasheer opened this issue 10 years ago • 1 comments

Hi, I have an issue in my laravel sentinel application when in try to log in with Sentinel::authenticate( $credentials , $remember);method it dump user object whatever the route i call but when i try to login like this $user = Sentinel::findById(25); Sentinel::login($user); the every thing work fine. i have check with different user and by clearing all cookies and sessions in browser. below is my login

`

    public function doLogin( Request $request )            
    {              
    Sentinel::logout(null, true);
    try
    {
        $input = $request->all();
        $rules = [
            'username'    => 'required',
            'password' => 'required',
        ];
        $validator = Validator::make($input, $rules);
        if ($validator->fails())
        {
            return Redirect::back()
                ->withInput()
                ->withErrors($validator);
        }
        $remember = (bool) $request->get('remember', false);

        $credentials = [
            'login'    => $input['username'],
            'password' => $input['password'],
        ];

        $user = Sentinel::authenticate( $credentials , $remember); 
        
        if ($user)
        {

            if ( $user->inRole('client') ) {
                return redirect('/client/jobs'); 
            }

            if ( $user->inRole('admin') ) {
                return redirect('/msp/jobs'); 
            }

            return "Logged In";
        }
        
        Session::flash('error' , "Invalid email or password.");
        return redirect('login')->withInput($request->except('password'));
    }
    
    catch (NotActivatedException $e)
    
    {
        $error = 'Account is not activated!';
        Session::flash('error' , $error );
        
        return Redirect::to('reactivate')->with('user', $e->getUser());
    }

    catch ( \App\Shahid\Checkpoint\BannedExeption $ex) {

        $error = 'Your Account is Banned!';
        Session::flash('error' , $error );
        return redirect('login');
        
    }
    
    catch (ThrottlingException $e)
    
    {
        $delay = $e->getDelay();
        $error = "Your account is blocked for {$delay} second(s).";
        Session::flash('error' , $error );
        return redirect('login');
    }
    
    return Redirect::back()
        ->withInput()
        ->withErrors($errors);
} //doLogin`

In my Controller constructor i have

    protected $user;       
    protected $client; 
    public function __construct(  )
    {    
        $this->user = Sentinel::getUser();
        $this->client = getClientByUserId( $this->user->id ); 
    
    }

shahidbasheer avatar Nov 22 '16 04:11 shahidbasheer

my bad i made new exception and check() was dumping there spent two days. :)

shahidbasheer avatar Nov 22 '16 08:11 shahidbasheer