-
-
Save anonymous/f0f576a74d976e6b48e3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Created by PhpStorm. | |
* User: magr0s | |
* Date: 12.09.2015 | |
* Time: 19:17 | |
*/ | |
require_once MODX_PROCESSORS_PATH.'security/user/create.class.php'; | |
class siteWebUserCreateProcessor extends modUserCreateProcessor{ | |
public $permission = ''; | |
function initialize(){ | |
$this->setDefaultProperties(array( | |
'passwordgenmethod' => 'spec', | |
'specifiedpassword' => $this->getProperty('password'), | |
'confirmpassword' => $this->getProperty('password'), | |
'email' => $this->getProperty('username'), | |
'passwordnotifymethod' => 'e', | |
)); | |
return parent::initialize(); | |
} | |
function sendNotificationEmail() { | |
$confirmUrl = $this->prepareActivationUrl(); | |
if ($this->getProperty('passwordnotifymethod') == 'e') { | |
$message = $this->modx->getOption('websignupemail_message'); | |
$placeholders = array( | |
'uid' => $this->object->get('username'), | |
'pwd' => $this->newPassword, | |
'ufn' => $this->profile->get('fullname'), | |
'sname' => $this->modx->getOption('site_name'), | |
'saddr' => $this->modx->getOption('emailsender'), | |
'semail' => $this->modx->getOption('emailsender'), | |
'surl' => $this->modx->getOption('url_scheme') . $this->modx->getOption('http_host'), | |
'aurl' => $confirmUrl, | |
); | |
foreach ($placeholders as $k => $v) { | |
$message = str_replace('[[+'.$k.']]',$v,$message); | |
} | |
$this->object->sendEmail($message); | |
} | |
} | |
function prepareActivationUrl(){ | |
$pword = $this->newPassword; | |
$confirmParams['ap'] = urlencode(base64_encode($pword)); | |
$confirmParams['au'] = urlencode(base64_encode($this->object->get(username))); | |
$confirmUrl = $this->modx->makeUrl($this->modx->resource->id, '', $confirmParams, 'full'); | |
$this->setCachePassword($pword); | |
return $confirmUrl; | |
} | |
function setCachePassword($password){ | |
$this->modx->getService('registry', 'registry.modRegistry'); | |
$this->modx->registry->addRegister('login','registry.modFileRegister'); | |
$this->modx->registry->login->connect(); | |
$this->modx->registry->login->subscribe('/useractivation/'); | |
$this->modx->registry->login->send('/useractivation/',array($this->object->get('username') => $password),array( | |
'ttl' => 180*60, | |
)); | |
$this->object->set('cachepwd',md5($password)); | |
$success = $this->object->save(); | |
if (!$success){ | |
$this->modx->log(modX::LOG_LEVEL_ERROR,'[Register] Could not update cachepwd for activation for User: '.$this->object->get('username')); | |
} | |
} | |
} | |
return 'siteWebUserCreateProcessor'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment