コード例 #1
0
 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.');
     }
 }
コード例 #2
0
 /**
  * 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);
 }
コード例 #3
0
 /**
  * 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');
 }
コード例 #4
0
 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());
 }