{ $app = \Slim\Slim::getInstance(); if ($app->authenticated) { return true; } $app->response()->status(401); //<! Unhautorized Error return false; } /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Routes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ $app->get('/', function () { echo "Welcome to P2P-WebAPI"; }); $app->get('/validateemail/:email', function ($email) { $authService = new AuthenticationService(); echo json_encode($authService->validateEmail($email)); }); $app->post('/signin', function () { $request = \Slim\Slim::getInstance()->request(); $user = json_decode($request->getBody()); $authService = new AuthenticationService(); echo json_encode($authService->signIn($user)); }); $app->post('/signup', function () { $request = \Slim\Slim::getInstance()->request(); $user = json_decode($request->getBody()); $authService = new AuthenticationService(); echo json_encode($authService->signUp($user)); }); $app->get('/avatar', function () { if (accessIsOK()) {