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.'); } }
public function testFindByName() { Sentry::shouldReceive('findGroupByName')->with('Admin')->once()->andReturn(array()); $this->assertEquals(array(), $this->groups->findByName('Admin')); Sentry::shouldReceive('findGroupByName')->once()->andThrow('Cartalyst\\Sentry\\Groups\\GroupNotFoundException'); $this->assertFalse($this->groups->findByName('Moderator')); $this->assertNotNull($this->groups->getError()); }