diff --git a/php/controllers/LoginController.php b/php/controllers/LoginController.php index 9c37033..3196c30 100644 --- a/php/controllers/LoginController.php +++ b/php/controllers/LoginController.php @@ -39,12 +39,18 @@ class LoginController extends Controller $errors['password'] = "Please enter a Password."; } if(!empty($username) && !empty($password)) { - if($login->login($username, $password)) { - $this->container->setNotice("Success! You have been successfully logged in."); - $this->doRedirect(); - } else { - $errors['login'] = "Invalid credentials. Please check your username and password, and try again."; + try { + if($login->login($username, $password)) { + $this->container->setNotice("Success! You have been successfully logged in."); + $this->doRedirect(); + } else { + $errors['login'] = "Invalid credentials. Please check your username and password, and try again."; + } + } catch (StorageException $e) { + $errors['login'] = "Error: Database is not available."; } + + } } diff --git a/php/includes/Login.php b/php/includes/Login.php index 45d2bbd..0467604 100644 --- a/php/includes/Login.php +++ b/php/includes/Login.php @@ -68,8 +68,11 @@ class Login $usernameCanonical = $this->ircToLower($username); // Storage get salt, hashedPassword, capabilities for user - $results = $this->storage->getLoginByUsernameCanonical($usernameCanonical); - + try { + $results = $this->storage->getLoginByUsernameCanonical($usernameCanonical); + } catch(StorageException $e) { + throw $e; + } if(count($results) < 1) { return false; }