public function executeLater() { if ($this->submit && $this->controller->validate()) { $email = org_glizy_Request::get('user_email', ''); $ar = org_glizy_ObjectFactory::createModel('org.glizy.models.User'); if ($ar->find(array('user_loginId' => $email))) { // TODO tradurre $this->view->validateAddError('L\'email è già presente nel database, usare un\'altra email o richiedere la password'); return; } $fields = $ar->getFields(); foreach ($fields as $k => $v) { if (__Request::exists($k)) { $ar->{$k} = __Request::get($k); } } $ar->user_FK_usergroup_id = __Config::get('USER_DEFAULT_USERGROUP'); $ar->user_isActive = __Config::get('USER_DEFAULT_ACTIVE_STATE'); $ar->user_password = glz_password(__Request::get('user_password')); $ar->user_loginId = $email; $ar->user_email = $email; $ar->user_dateCreation = new org_glizy_types_DateTime(); $ar->save(); $this->changeAction('registrationConfirm'); } }
public function loginFromRequest($loginIdField, $passwordFields, $rememberField = false, $readFromCookie = false) { $loginId = trim(__Request::get($loginIdField, $readFromCookie ? $_COOKIE['glizy_username'] : '')); $psw = trim(__Request::get($passwordFields, $readFromCookie ? $_COOKIE['glizy_password'] : '')); $remember = __Request::get($rememberField, 0); $this->login($loginId, glz_password($psw), $remember); }
public function executeLater() { if ($this->user->isLogged() && $this->submit && $this->controller->validate()) { $ar = org_glizy_ObjectFactory::createModel('org.glizy.models.User'); $ar->load($this->user->id); $email = org_glizy_Request::get('user_email', ''); if ($email != $ar->user_loginId) { $ar2 = org_glizy_ObjectFactory::createModel('org.glizy.models.User'); if ($ar2->find(array('user_loginId' => $email)) && $ar2->user_id != $ar->user_id) { $this->view->validateAddError('L\'email è già presente nel database, usare un\'altra email'); return; } } // TODO migliorare così siamo esposti a problemi di sicurezza $fields = $ar->getFields(); foreach ($fields as $k => $v) { if ($k == 'user_password') { continue; } if (__Request::exists($k)) { $ar->{$k} = __Request::get($k); } } $password = __Request::get('user_password'); if ($password) { $ar->user_password = glz_password($password); } $ar->user_loginId = $email; $ar->user_email = $email; $ar->save(); $this->changeAction('modifyConfirm'); } }