Skip to content

Instantly share code, notes, and snippets.

Created January 19, 2015 12:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/a3f98e442a4ca507e34b to your computer and use it in GitHub Desktop.
Save anonymous/a3f98e442a4ca507e34b to your computer and use it in GitHub Desktop.
try {
$this->user->validarDadosLogin();
//Autenticaçõa na base de dados
$auth = new Auth($this->user, $this->session, DB::getCon());
$userId = $auth->login();
}
catch (InvalidDataException $e) {
//Dados inválidos
$erro = $e->getMessage();
}
catch (DatabaseException $e) {
//Erro no bdd
$erro = $e->getMessage();
}
catch (AuthException $e) {
//Usuário inválido
$erro = $e->getMessage();
}
catch (Exception $e) {
$erro = 'Erro inesperrado';
}
// OU
if ( $this->user->validarDadosLogin() ) {
//Autenticaçõa na base de dados
$auth = new Auth($this->user, $this->session, DB::getCon());
$userId = $auth->login();
if (!$userId) {
$erro = 'Usuário inválido';
}
}
else {
$erro = $this->user->getErro();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment