aboutsummaryrefslogtreecommitdiff
path: root/src/filters.php
blob: ae59923b46d9c78f5306543c9dacb0bbc2879ce0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php
Route::filter('administrator', function(){
    $auth = app('api.auth');
    if (empty($auth->user()) || !$auth->user()->isAdministrator) {
        throw new \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException();
    }
});

Route::filter('current_user', function() {
    $auth = app('api.auth');
    if (empty($auth->user()) || Route::input('user') != $auth->user()->email) {
        throw new \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException();
    }
});