Bubble up db error for login

This commit is contained in:
rootcoma 2013-12-06 10:44:21 -08:00
parent ba7ec636f4
commit d027fa27b6
2 changed files with 16 additions and 7 deletions

View File

@ -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("<strong>Success!</strong> 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("<strong>Success!</strong> 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.";
}
}
}

View File

@ -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;
}