Example #1
0
 public function __construct(PhoneInterface $phones, PhoneForm $phoneForm, FaxInterface $faxes, Users $users, GroupInterface $groups)
 {
     parent::__construct();
     $this->users = $users;
     $this->phones = $phones;
     $this->faxes = $faxes;
     $this->phoneForm = $phoneForm;
     $this->groups = $groups;
     $id = Route::input('phones');
     $resource = 'Faxbox\\Repositories\\Phone\\PhoneInterface';
     $admin = Permissions::name($resource, 'admin', $id);
     $this->beforeFilter('auth');
     $this->beforeFilter('accessResource:' . $admin, ['only' => ['delete']]);
     $this->beforeFilter('accessResource:purchase_numbers', ['except' => ['delete']]);
 }
Example #2
0
        Session::flash('error', trans('users.notfound'));
        return Redirect::guest('login');
    } catch (Cartalyst\Sentry\Groups\GroupNotFoundException $e) {
        Session::flash('error', trans('groups.notfound'));
        return Redirect::guest('login');
    }
});
Route::filter('accessResource', function ($route, $request, $value) {
    if (!Sentry::check()) {
        return Redirect::guest('login');
    }
    list($class, $permission) = explode('_', $value);
    try {
        $user = Sentry::getUser();
        // todo add more generic check in here to lookup access based on resource ID
        if ($user->hasAccess($value) || $user->hasAccess(Permissions::name($class, 'admin'))) {
            return;
        }
        Session::flash('error', trans('users.noaccess'));
        return Redirect::route('home');
    } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
        Session::flash('error', trans('users.notfound'));
        return Redirect::guest('login');
    } catch (Cartalyst\Sentry\Groups\GroupNotFoundException $e) {
        Session::flash('error', trans('groups.notfound'));
        return Redirect::guest('login');
    }
});
/*
|--------------------------------------------------------------------------
| Guest Filter