/** * Autenticates the User */ function onLogin() { try { TTransaction::open('permission'); $data = $this->form->getData('StdClass'); $this->form->validate(); $user = SystemUser::autenticate($data->login, $data->password); if ($user) { TSession::regenerate(); $programs = $user->getPrograms(); $programs['LoginForm'] = TRUE; TSession::setValue('logged', TRUE); TSession::setValue('login', $data->login); TSession::setValue('username', $user->name); TSession::setValue('frontpage', ''); TSession::setValue('programs', $programs); $frontpage = $user->frontpage; SystemAccessLog::registerLogin(); if ($frontpage instanceof SystemProgram and $frontpage->controller) { TApplication::gotoPage($frontpage->controller); // reload TSession::setValue('frontpage', $frontpage->controller); } else { TApplication::gotoPage('EmptyPage'); // reload TSession::setValue('frontpage', 'EmptyPage'); } } TTransaction::close(); } catch (Exception $e) { new TMessage('error', $e->getMessage()); TSession::setValue('logged', FALSE); TTransaction::rollback(); } }