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.'); } }
/** * 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); }
/** * Show the form for editing the specified group. * * @param int $id */ public function edit($id) { if ($group = $this->groups->findById($id)) { return View::make('laravel-sentry-backend::groups.edit', compact('group')); } return Redirect::route('groups.index'); }
public function testFindById() { Sentry::shouldReceive('findGroupById')->with(1)->once()->andReturn(array()); $this->assertEquals(array(), $this->groups->findById(1)); Sentry::shouldReceive('findGroupById')->once()->andThrow('Cartalyst\\Sentry\\Groups\\GroupNotFoundException'); $this->assertFalse($this->groups->findById(10)); $this->assertNotNull($this->groups->getError()); }