/**
  * Remove user from a group.
  *
  * @param int $userId
  * @param int $groupId
  * @return \Illuminate\Http\RedirectResponse
  */
 public function destroy($userId, $groupId)
 {
     $user = $this->users->findById($userId);
     $group = $this->groups->findById($groupId);
     $this->users->removeGroup($user, $group);
     return Redirect::route('users.groups.index', $userId);
 }
 public function testFindById()
 {
     Sentry::shouldReceive('findUserById')->with(1)->once()->andReturn(true);
     $this->assertTrue($this->users->findById(1));
     Sentry::shouldReceive('findUserById')->once()->andThrow('Cartalyst\\Sentry\\Users\\UserNotFoundException');
     $this->assertFalse($this->users->findById(10));
     $this->assertNotNull($this->users->getError());
 }
 /**
  * Updated user password in storage.
  */
 public function update()
 {
     $id = Input::get('id');
     $code = Input::get('code');
     $user = $this->users->findById($id);
     if ($user && $code) {
         if (!$this->validator->validate(Input::all())) {
             return Redirect::route('password-reset.edit', array($id, $code))->withErrors($this->validator->getErrors());
         }
         if ($user->checkResetPasswordCode($code) && $user->attemptResetPassword($code, Input::get('password'))) {
             return Redirect::route('session.create')->with('success_password_reset', true);
         }
     }
     return Redirect::route('password-reset.create');
 }
 /**
  * Activate the specified user in storage.
  *
  * @param int $id
  * @return \Illuminate\Http\RedirectResponse
  */
 public function activate($id)
 {
     $this->users->activate($id, $this->users->findById($id)->getActivationCode());
     return Redirect::route('users.index');
 }