Exemplo n.º 1
0
 function index()
 {
     $id = $this->param('j_user_login');
     if ($id === null) {
         $rep = $this->getResponse('redirect');
         $rep->action = 'master_admin~default:index';
         return $rep;
     }
     if ($this->personalView && $id != jAuth::getUserSession()->login) {
         jMessage::add(jLocale::get('jelix~errors.acl.action.right.needed'), 'error');
         $rep = $this->getResponse('redirect');
         $rep->action = 'master_admin~default:index';
         return $rep;
     }
     $rep = $this->getResponse('html');
     $tpl = new jTpl();
     $tpl->assign('id', $id);
     $tpl->assign('randomPwd', jAuth::getRandomPassword());
     $tpl->assign('personalview', $this->personalView);
     if ($this->personalView) {
         $tpl->assign('viewaction', 'user:index');
     } else {
         $tpl->assign('viewaction', 'default:view');
     }
     $rep->body->assign('MAIN', $tpl->fetch('password_change'));
     return $rep;
 }
Exemplo n.º 2
0
 function install()
 {
     if (self::$key === null) {
         self::$key = jAuth::getRandomPassword(30, true);
     }
     $authconfig = $this->config->getValue('auth', 'coordplugins');
     $authconfigMaster = $this->config->getValue('auth', 'coordplugins', null, true);
     $forWS = in_array($this->entryPoint->type, array('json', 'jsonrpc', 'soap', 'xmlrpc'));
     if (!$authconfig || $forWS && $authconfig == $authconfigMaster) {
         if ($forWS) {
             $pluginIni = 'authsw.coord.ini.php';
         } else {
             $pluginIni = 'auth.coord.ini.php';
         }
         $authconfig = dirname($this->entryPoint->configFile) . '/' . $pluginIni;
         if ($this->firstExec('auth:' . $authconfig)) {
             // no configuration, let's install the plugin for the entry point
             $this->config->setValue('auth', $authconfig, 'coordplugins');
             if (!file_exists(jApp::configPath($authconfig))) {
                 $this->copyFile('var/config/' . $pluginIni, jApp::configPath($authconfig));
             }
         }
     }
     $localConfigIni = $this->entryPoint->localConfigIni;
     $key = $localConfigIni->getValue('persistant_crypt_key', 'coordplugin_auth');
     if ($key === 'exampleOfCryptKey' || $key == '') {
         $localConfigIni->getMaster()->setValue('persistant_crypt_key', self::$key, 'coordplugin_auth');
     }
 }
 function install()
 {
     if (self::$key === null) {
         self::$key = jAuth::getRandomPassword(30, true);
     }
     $conf = $this->config->getValue('auth', 'coordplugins');
     if ($conf != '1') {
         $conff = jApp::configPath($conf);
         if (file_exists($conff)) {
             $ini = new jIniFileModifier($conff);
             $ini->removeValue('persistant_crypt_key');
             $ini->save();
         }
     }
     $localConfigIni = $this->entryPoint->localConfigIni;
     $localConfigIni->getMaster()->setValue('persistant_crypt_key', self::$key, 'coordplugin_auth');
 }
Exemplo n.º 4
0
 /**
  * send a new password 
  */
 function send()
 {
     $repError = $this->_check();
     if ($repError) {
         return $repError;
     }
     $rep = $this->getResponse("redirect");
     $rep->action = "password:index";
     $form = jForms::fill('password');
     if (!$form->check()) {
         return $rep;
     }
     $login = $form->getData('pass_login');
     $user = jAuth::getUser($login);
     if (!$user) {
         $form->setErrorOn('pass_login', jLocale::get('password.login.doesnt.exist'));
         return $rep;
     }
     if ($user->email != $form->getData('pass_email')) {
         $form->setErrorOn('pass_email', jLocale::get('password.email.unknown'));
         return $rep;
     }
     $pass = jAuth::getRandomPassword(8);
     $key = substr(md5($login . '-' . $pass), 1, 10);
     $user->status = JCOMMUNITY_STATUS_PWD_CHANGED;
     $user->request_date = date('Y-m-d H:i:s');
     $user->keyactivate = $key;
     jAuth::updateUser($user);
     $mail = new jMailer();
     $mail->From = jApp::config()->mailer['webmasterEmail'];
     $mail->FromName = jApp::config()->mailer['webmasterName'];
     $mail->Sender = jApp::config()->mailer['webmasterEmail'];
     $mail->Subject = jLocale::get('password.mail.pwd.change.subject');
     $tpl = new jTpl();
     $tpl->assign(compact('login', 'pass', 'key'));
     $tpl->assign('server', $_SERVER['SERVER_NAME']);
     $mail->Body = $tpl->fetch('mail_password_change', 'text');
     $mail->AddAddress($user->email);
     //$mail->SMTPDebug = true;
     $mail->Send();
     jForms::destroy('password');
     $rep->action = "password:confirmform";
     return $rep;
 }
Exemplo n.º 5
0
 function index()
 {
     $id = $this->param('id');
     if ($id === null) {
         $rep = $this->getResponse('redirect');
         $rep->action = 'master_admin~default:index';
         return $rep;
     }
     $rep = $this->getResponse('html');
     $tpl = new jTpl();
     $tpl->assign('id', $id);
     $tpl->assign('randomPwd', jAuth::getRandomPassword());
     $tpl->assign('personalview', $this->personalView);
     if ($this->personalView) {
         $tpl->assign('viewaction', 'user:index');
     } else {
         $tpl->assign('viewaction', 'default:view');
     }
     $rep->body->assign('MAIN', $tpl->fetch('password_change'));
     return $rep;
 }
Exemplo n.º 6
0
 /**
  * save new user and send an email for a confirmation, with
  * a key to activate the account
  */
 function save()
 {
     if (jAuth::isConnected()) {
         return $this->noaccess();
     }
     $rep = $this->getResponse("redirect");
     $rep->action = "registration:index";
     $form = jForms::get('registration');
     if (!$form) {
         return $rep;
     }
     jEvent::notify('jcommunity_registration_init_form', array('form' => $form));
     $form->initFromRequest();
     if (!$form->check()) {
         return $rep;
     }
     $login = $form->getData('reg_login');
     if (jAuth::getUser($login)) {
         $form->setErrorOn('reg_login', jLocale::get('register.form.login.exists'));
         return $rep;
     }
     $pass = jAuth::getRandomPassword(8);
     $key = substr(md5($login . '-' . $pass), 1, 10);
     $user = jAuth::createUserObject($login, $pass);
     $user->email = $form->getData('reg_email');
     $user->nickname = $login;
     $user->status = JCOMMUNITY_STATUS_NEW;
     $user->request_date = date('Y-m-d H:i:s');
     $user->keyactivate = $key;
     $ev = jEvent::notify('jcommunity_registration_prepare_save', array('form' => $form, 'user' => $user));
     if (count($form->getErrors())) {
         return $rep;
     }
     $responses = $ev->getResponse();
     $hasErrors = false;
     foreach ($responses as $response) {
         if (isset($response['errorRegistration']) && $response['errorRegistration'] != "") {
             jMessage::add($response['errorRegistration'], 'error');
             $hasErrors = true;
         }
     }
     if ($hasErrors) {
         return $rep;
     }
     jAuth::saveNewUser($user);
     jEvent::notify('jcommunity_registration_after_save', array('form' => $form, 'user' => $user));
     $gJConfig = jApp::config();
     $mail = new jMailer();
     $mail->From = $gJConfig->mailer['webmasterEmail'];
     $mail->FromName = $gJConfig->mailer['webmasterName'];
     $mail->Sender = $gJConfig->mailer['webmasterEmail'];
     $mail->Subject = jLocale::get('register.mail.new.subject');
     $tpl = new jTpl();
     $tpl->assign(compact('login', 'pass', 'key'));
     $tpl->assign('server', $_SERVER['SERVER_NAME']);
     $mail->Body = $tpl->fetch('mail_registration', 'text');
     $mail->AddAddress($user->email);
     $mail->Send();
     jForms::destroy('registration');
     $rep->action = "registration:confirmform";
     $rep->params = array('login' => $login);
     return $rep;
 }
Exemplo n.º 7
0
 /**
  * display a form to create a record
  */
 function create()
 {
     $form = jForms::get($this->form);
     if ($form == null) {
         $form = jForms::create($this->form);
     }
     $rep = $this->getResponse('html');
     $tpl = new jTpl();
     $tpl->assign('id', null);
     $tpl->assign('form', $form);
     $tpl->assign('randomPwd', jAuth::getRandomPassword());
     jEvent::notify('jauthdbAdminEditCreate', array('form' => $form, 'tpl' => $tpl));
     $rep->body->assign('MAIN', $tpl->fetch('crud_edit'));
     return $rep;
 }