public static function getLoggedInUser() { if (!array_key_exists('userID', $_SESSION)) { return false; } return User::getById($_SESSION['userID']); }
foreach ($receivers as $receiver) { $mail->addTo($receiver->getEmail()); } switch ($config['mail_method']) { case "sendmail": $mailer = new SendmailMailer(); break; case "smtp": $mailer = new \Nette\Mail\SmtpMailer($config['smtpmail_settings']); } $mailer->send($mail); print "<html><pre>"; print_r($receivers); }); $app->get('/user/:id', function ($id) { outputJSON(User::getById($id)); }); $app->post('/auth/login', function () use($app) { $body = json_decode($app->request->getBody()); try { $user = User::getByUsername($body->username); try { $user->login($body->password); if ($user) { outputJSON(array('status' => 'success', 'message' => 'User logged in')); } } catch (PasswordIncorrectException $e) { outputError($e->getMessage(), $e->getCode()); } } catch (UserNotFoundException $e) { outputError($e->getMessage(), $e->getCode());