public function testGetUser()
 {
     Sentry::shouldReceive('getUser')->once()->withNoArgs()->andReturn(array());
     $this->assertEquals(array(), $this->auth->getUser());
     Sentry::shouldReceive('getUser')->once()->andThrow('Cartalyst\\Sentry\\Users\\UserNotFoundException');
     $this->assertFalse($this->auth->getUser());
 }
 protected function createOldPasswordValidator()
 {
     $user = $this->auth->getUser();
     Validator::extend('sentry_old_password', function ($attribute, $value, $parameters) use($user) {
         return $user->checkPassword($value);
     });
 }
 public function filter($route, $request, $group)
 {
     $group = is_int($group) ? $this->groups->findById($group) : $this->groups->findByName($group);
     if ($group && (!$this->auth->check() || !$this->auth->getUser()->inGroup($group))) {
         return App::abort(401, 'You are not authorized.');
     }
 }
 /**
  * Store new password.
  *
  * @param int $userId
  * @return \Illuminate\Http\RedirectResponse
  */
 public function store($userId)
 {
     $user = $this->auth->getUser();
     if ($user && $userId == $user->id) {
         if ($this->validator->validate(Input::all())) {
             $user->password = Input::get('password');
             $user->save();
             return Redirect::route('profile.index')->with('success_password_change', true);
         }
         return Redirect::route('profile.password.create', $user->id)->withErrors($this->validator->getErrors());
     }
     return Redirect::route('profile.index');
 }
 /**
  * Update the user profile in storage.
  *
  * @param int $id
  * @return Response
  */
 public function update($id)
 {
     if (!$this->auth->check()) {
         return Redirect::route('session.create');
     }
     $user = $this->auth->getUser();
     if ($id == $user->id) {
         $user->first_name = Input::get('first_name');
         $user->last_name = Input::get('last_name');
         $user->save();
     }
     return Redirect::route('profile.index');
 }
 public function filter()
 {
     if (!$this->auth->check() || !$this->auth->getUser()->isSuperuser()) {
         return App::abort(401, 'You are not authorized.');
     }
 }