Merge pull request #19 from amalfra/dev
Connection to database failed. Ensure api is writable.
This commit is contained in:
commit
43075eec67
8
api/api.php
Normal file → Executable file
8
api/api.php
Normal file → Executable file
@ -15,8 +15,16 @@ $app->response->headers->set('Content-Type', 'application/json');
|
||||
$jsonResponse = new JsonResponse();
|
||||
require_once('helpers.php'); // Must come after $jsonResponse exists.
|
||||
|
||||
// Catch Exception if connection to DB failed
|
||||
try {
|
||||
R::setup('sqlite:taskboard.db');
|
||||
createInitialUser();
|
||||
} catch(Exception $e) {
|
||||
$app->response->setStatus(503);
|
||||
$jsonResponse->message = 'Connection to Database failed. Ensure api is writable.';
|
||||
|
||||
$app->response->setBody($jsonResponse->asJson());
|
||||
}
|
||||
|
||||
$app->notFound(function() use ($app, $jsonResponse) {
|
||||
$app->response->setStatus(404);
|
||||
|
7
api/userRoutes.php
Normal file → Executable file
7
api/userRoutes.php
Normal file → Executable file
@ -6,7 +6,7 @@ $app->post('/login', function() use ($app, $jsonResponse) {
|
||||
$expires = ($data->rememberme)
|
||||
? (2 * 7 * 24 * 60 * 60) /* Two weeks */
|
||||
: (1.5 * 60 * 60) /* One and a half hours */;
|
||||
try {
|
||||
|
||||
$lookup = R::findOne('user', ' username = ? ', [$data->username]);
|
||||
|
||||
$jsonResponse->message = 'Invalid username or password.';
|
||||
@ -30,11 +30,6 @@ $app->post('/login', function() use ($app, $jsonResponse) {
|
||||
$app->response->setStatus(200);
|
||||
}
|
||||
}
|
||||
} catch (Exception $ex) {
|
||||
}
|
||||
if (!is_writable('taskboard.db')) {
|
||||
$jsonResponse->message = 'The api directory is not writable.';
|
||||
}
|
||||
$app->response->setBody($jsonResponse->asJson());
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user