Skip to content

Commit

Permalink
Updates to make bootstrapping easier.
Browse files Browse the repository at this point in the history
  • Loading branch information
csev committed Feb 5, 2021
1 parent 096e890 commit 8f7360b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion admin/gate.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,17 @@
die('Please set $CFG->adminpw to a plaintext or hashed string');
}

if ( $CFG->google_client_id && ! U::get($_SESSION,'id') ) {
// Make sure we have an initialized database before sending to login.php
try {
define('PDO_WILL_CATCH', true);
$PDOX = \Tsugi\Core\LTIX::getConnection();
$stmt = $PDOX->queryReturnError("SELECT key_id FROM {$CFG->dbprefix}lti_key LIMIT 1");
$havedatabase = $stmt->success;
} catch(\PDOException $ex){
$havedatabase = false;
}

if ( $havedatabase && $CFG->google_client_id && ! U::get($_SESSION,'id') ) {
$_SESSION['login_return'] = $rest_path->full;
Output::doRedirect($CFG->wwwroot.'/login.php');
return;
Expand Down
2 changes: 1 addition & 1 deletion admin/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
require_once("sanity.php");
$PDOX = false;
try {
define('PDO_WILL_CATCH', true);
if ( ! defined('PDO_WILL_CATCH') ) define('PDO_WILL_CATCH', true);
$PDOX = \Tsugi\Core\LTIX::getConnection();
} catch(\PDOException $ex){
$PDOX = false; // sanity-db-will re-check this below
Expand Down

0 comments on commit 8f7360b

Please sign in to comment.