throw new Exception('Niekompletne dane.', 400);
            }
            $notify_text = validateString('wiadomość', $postVars['notify_text'], 6, 2048);
            $result = $thread->notify($id, $notify_text);
            $email_to = implode(',', $result);
            $subject = 'Powiadomienie';
            $message = $notify_text . " \nJeśli nie chcesz otrzymywać wiadomości e-mail, zaloguj się na www.bariery.wroclaw.pl i wycofaj subskrypcję dla zgłoszeń.";
            $headers = 'From: admin@bariery.wroclaw.pl' . "\r\n" . 'Reply-To: no-reply@bariery.wroclaw.pl' . "\r\n" . 'X-Mailer: PHP/' . phpversion();
            @mail($email_to, $subject, $message, $headers);
            jsonSuccess($app, $result);
        } catch (Exception $e) {
            jsonError($app, $e);
        }
    });
    $app->delete('/id/:id', validatePrivileges(array('administrator')), function ($id) use($app, $thread) {
        try {
            $result = $thread->delete($id);
            jsonSuccess($app, $result);
        } catch (Exception $e) {
            jsonError($app, $e);
        }
    });
    $app->delete('/marker/id/:id', validatePrivileges(array('administrator')), function ($id) use($app, $thread) {
        try {
            $result = $thread->deleteMarker($id);
            jsonSuccess($app, $result);
        } catch (Exception $e) {
            jsonError($app, $e);
        }
    });
});
             } else {
                 if (!empty($postVars['google_id'])) {
                     $google_id = validateString('google_id', $postVars['google_id'], 1, 32);
                     $arguments['google_id'] = $google_id;
                 } else {
                     throw new Exception('Niekompletne dane.', 400);
                 }
             }
         }
         $result = $user->authorize($arguments);
         jsonSuccess($app, $result);
     } catch (Exception $e) {
         jsonError($app, $e);
     }
 });
 $app->get('/unauthorize', validatePrivileges(array('user', 'moderator', 'administrator')), function () use($app, $user) {
     try {
         // Walidacja danych
         $token = validateToken($GLOBALS['token']);
         $result = $user->unauthorize($token);
         jsonSuccess($app, $result);
     } catch (Exception $e) {
         echo "walidacja";
         jsonError($app, $e);
     }
 });
 $app->post('/lostpassword', function () use($app, $user, $config) {
     try {
         // Walidacja danych
         $postVars = $app->request->post();
         // Walidacja danych
            jsonError($app, $e);
        }
    });
    $app->put('/id/:id/status/:status', validatePrivileges(array('user', 'administrator')), function ($id, $status) use($app, $comment) {
        try {
            $c = $comment->getByID($id);
            if ($GLOBALS['privileges'] == 'user' && $status != 0) {
                throw new Exception('Jako użytkownik możesz jedynie zgłaszać nadużycia.', 403);
            }
            if ($GLOBALS['privileges'] == 'user' && $c['status_id'] > 1) {
                throw new Exception('Możesz zgłaszać nadużycia jedynie dla niezatwierdzonych komentarzy.', 403);
            }
            $result = $comment->setStatus($id, $status);
            jsonSuccess($app, $result);
        } catch (Exception $e) {
            jsonError($app, $e);
        }
    });
    $app->delete('/id/:id', validatePrivileges(array('user', 'administrator')), function ($id) use($app, $comment) {
        try {
            $c = $comment->getByID($id);
            if ($GLOBALS['privileges'] == 'user' && $GLOBALS['user_id'] != $c['user_id']) {
                throw new Exception('Nie jesteś autorem komentarza.', 403);
            }
            $result = $comment->delete($id);
            jsonSuccess($app, $result);
        } catch (Exception $e) {
            jsonError($app, $e);
        }
    });
});
<?php

$app->group('/vote', function () use($app) {
    $vote = new \Model\Vote();
    $app->post('/', validatePrivileges(array('user', 'moderator', 'administrator')), function () use($app, $vote) {
        try {
            $postVars = $app->request->post();
            // Walidacja danych
            if (empty($postVars['marker_id']) || empty($postVars['user_id']) || empty($postVars['vote'])) {
                throw new Exception('Niekompletne dane.', 400);
            }
            if ($postVars['vote'] <= 0 || $postVars['vote'] >= 11) {
                throw new Exception('Zły format danych.', 400);
            }
            $result = $vote->add($postVars['marker_id'], $postVars['user_id'], $postVars['vote']);
            jsonSuccess($app, $result);
        } catch (Exception $e) {
            jsonError($app, $e);
        }
    });
});