openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 46adcf614bf49211ea1cd58537377e64a38a5ab3
parent a0633ce4555086b4794b8b750a7b32b3259aa2ae
Author: dankert <devnull@localhost>
Date:   Mon,  5 Nov 2007 21:53:05 +0100

Aufruf von "addValidationError(...)" bei Eingabefehlern; Gast-Login erm?glichen.

Diffstat:
actionClasses/IndexAction.class.php | 99++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------
1 file changed, 80 insertions(+), 19 deletions(-)

diff --git a/actionClasses/IndexAction.class.php b/actionClasses/IndexAction.class.php @@ -141,7 +141,7 @@ class IndexAction extends Action * Login-Fehlermeldung erscheinen kann */ function showlogin() - { + { global $conf; $sso = $conf['security']['sso']; $ssl = $conf['security']['ssl']; @@ -149,7 +149,7 @@ class IndexAction extends Action $ssl_trust = false; $ssl_user_var = ''; extract( $ssl, EXTR_PREFIX_ALL, 'ssl' ); - + if ( $sso['enable'] ) { $authid = $this->getRequestVar( $sso['auth_param_name']); @@ -249,7 +249,7 @@ class IndexAction extends Action $this->callSubAction('show'); } - + foreach( $conf['database'] as $dbname=>$dbconf ) { if ( is_array($dbconf) && $dbconf['enabled'] ) @@ -282,7 +282,7 @@ class IndexAction extends Action // Html::debug($username); $this->setTemplateVar('force_username',$username); } - + $this->setTemplateVar('register' ,$conf['login' ]['register' ]); $this->setTemplateVar('send_password',$conf['login' ]['send_password']); $this->setTemplateVar('loginmessage',$this->getSessionVar('loginmessage')); @@ -388,6 +388,7 @@ class IndexAction extends Action if ( !$openId->checkAuthentication() ) { $this->addNotice('user',$openId->user,'LOGIN_OPENID_FAILED','error',array('name'=>$openId->user),array($openId->error) ); + $this->addValidationError('openid_url',''); $this->callSubAction('showlogin'); return; } @@ -414,6 +415,7 @@ class IndexAction extends Action { // Benutzer ist nicht in Benutzertabelle vorhanden (und angelegt werden soll er auch nicht). $this->addNotice('user',$username,'LOGIN_OPENID_FAILED','error',array('name'=>$username) ); + $this->addValidationError('openid_url',''); $this->callSubAction('showlogin'); return; } @@ -467,6 +469,7 @@ class IndexAction extends Action if ( ! $openId->login() ) { $this->addNotice('user',$openid_user,'LOGIN_OPENID_FAILED','error',array('name'=>$openid_user),array($openId->error) ); + $this->addValidationError('openid_url',''); $this->callSubAction('showlogin'); return; } @@ -489,12 +492,20 @@ class IndexAction extends Action { sleep(3); - if ( $this->mustChangePassword ) + if ( $this->mustChangePassword ) + { // Anmeldung gescheitert, Benutzer muss Kennwort ändern. $this->addNotice('user',$loginName,'LOGIN_FAILED_MUSTCHANGEPASSWORD','error' ); - else + $this->addValidationError('password1',''); + $this->addValidationError('password2',''); + } + else + { // Anmeldung gescheitert. $this->addNotice('user',$loginName,'LOGIN_FAILED','error',array('name'=>$this->getRequestVar('login_name')) ); + $this->addValidationError('login_name' ,''); + $this->addValidationError('login_password',''); + } $this->callSubAction('showlogin'); } @@ -602,14 +613,15 @@ class IndexAction extends Action function object() { + $this->evaluateRequestVars( array('objectid'=>$this->getRequestId()) ); + $user = Session::getUser(); - if ( ! is_object($user) ) - { - $this->callSubAction('show'); - } - $this->evaluateRequestVars( array('objectid'=>$this->getRequestId()) ); - $this->evaluateRequestVars( array('objectid'=>$this->getRequestId()) ); + if ( ! is_object($user) ) + { + $this->callSubAction('show'); + return; + } $user->loadRights( $project->projectid,$language->languageid ); Session::setUser( $user ); @@ -645,6 +657,16 @@ class IndexAction extends Action { global $REQ; $vars = $REQ + $add; + + $db = db_connection(); + if ( !is_object($db) ) + { + if ( isset($vars[REQ_PARAM_DATABASE_ID]) ) + $this->setDb($vars[REQ_PARAM_DATABASE_ID]); + else + die('no database available.'); + } + if ( isset($vars['objectid']) ) { @@ -757,8 +779,27 @@ class IndexAction extends Action global $PHP_AUTH_USER; global $PHP_AUTH_PW; - $user = Session::getUser(); + $user = Session::getUser(); + + // Gast-Login if ( ! is_object($user) ) + { + if ( $conf['security']['guest']['enable'] ) + { + $this->setDefaultDb(); + $username = $conf['security']['guest']['user']; + $user = User::loadWithName($username); + if ( $user->userid > 0 ) + $user->setCurrent(); + else + { + trigger_error("Guest login failed; User '$username' not found.",E_USER_NOTICE); + $user = null; + } + } + } + + if ( ! is_object($user) ) { switch( $conf['security']['login']['type'] ) { @@ -785,7 +826,8 @@ class IndexAction extends Action case 'form': // Benutzer ist nicht angemeldet - $this->callSubAction( 'showlogin' ); // Anzeigen der Login-Maske + $this->callSubAction( 'showlogin' ); // Anzeigen der Login-Maske + return; break; default: @@ -921,12 +963,19 @@ class IndexAction extends Action */ function registercode() { + if ( !$this->hasRequestVar('mail') ) + { + $this->addValidationError('mail'); + $this->callSubAction('register'); + return; + } + global $conf; srand ((double)microtime()*1000003); $registerCode = rand(); - Session::set('registerCode',$registerCode ); + Session::set('registerCode',$registerCode ); Session::set('registerMail',$this->getRequestVar('mail') ); $mail = new Mail($this->getRequestVar('mail'), @@ -981,7 +1030,10 @@ class IndexAction extends Action else { // Bestätigungscode stimmt nicht. - $this->addNotice('user',$newUser->name,'regcode_not_match','error'); + $this->addNotice('user',$newUser->name,'regcode_not_match','error'); +// $this->addValidationError('code'); + $this->callSubAction('register'); + return; } } @@ -1062,7 +1114,14 @@ class IndexAction extends Action * Einen Kennwort-Anforderungscode an den Benutzer senden. */ function passwordcode() - { + { + if ( !$this->hasRequestVar('username') ) + { + $this->addValidationError('username'); + $this->callSubAction('password'); + return; + } + $this->checkForDb(); $user = User::loadWithName( $this->getRequestVar("username") ); @@ -1076,9 +1135,11 @@ class IndexAction extends Action $eMail = new Mail( $user->mail,'password_commit_code','password_commit_code' ); $eMail->setVar('name',$user->getName()); $eMail->setVar('code',$code); - $eMail->send(); + if ( $eMail->send() ) + $this->addNotice('','user','mail_sent',OR_NOTICE_OK); + else + $this->addNotice('','user','error',OR_NOTICE_ERROR,array(),$eMail->error); - $this->addNotice('','user','mail_sent'); } else {