/** * 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); }
/** * 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'); }
/** * Attempt to activate user with code. * * @param int $id * @param string $code * @return \Illuminate\Http\RedirectResponse */ public function activate($id, $code) { if ($this->auth->check()) { return Redirect::route('profile.index'); } if ($this->users->activate($id, $code)) { return Redirect::route('session.create')->with('success_activation', true); } return Redirect::route('session.create')->with('error_activation', $this->users->getError()); }
public function testDelete() { $mock = m::mock(); Sentry::shouldReceive('findUserById')->with(1)->once()->andReturn($mock); $mock->shouldReceive('delete')->once()->andReturn(true); $this->assertTrue($this->users->delete(1)); Sentry::shouldReceive('findUserById')->once()->andThrow('Cartalyst\\Sentry\\Users\\UserNotFoundException'); $this->assertFalse($this->users->delete(10)); $this->assertNotNull($this->users->getError()); }
/** * 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'); }