Example #1
0
 /**
  * Validate the login
  */
 function onLogin()
 {
     try {
         TTransaction::open('library');
         $data = $this->form->getData('StdClass');
         // validate form data
         $this->form->validate();
         $language = $data->language ? $data->language : 'en';
         TAdiantiCoreTranslator::setLanguage($language);
         TApplicationTranslator::setLanguage($language);
         $auth = User::autenticate($data->{'user'}, $data->{'password'});
         if ($auth) {
             TSession::setValue('logged', TRUE);
             TSession::setValue('login', $data->{'user'});
             TSession::setValue('language', $data->language);
             // reload page
             TApplication::executeMethod('SetupPage', 'onSetup');
         }
         TTransaction::close();
         // finaliza a transação
     } catch (Exception $e) {
         TSession::setValue('logged', FALSE);
         // exibe a mensagem gerada pela exceção
         new TMessage('error', '<b>Erro</b> ' . $e->getMessage());
         // desfaz todas alterações no banco de dados
         TTransaction::rollback();
     }
 }