/** {@inheritDoc} */ public function process() { $propKey = $this->getProperty('propkey'); if (empty($propKey)) { return $this->el->failure($this->el->lexicon('err_propkey_ns')); } $properties = $this->el->getProperties($propKey); if (empty($properties)) { return $this->el->failure($this->el->lexicon('err_properties_ns')); } if (!$this->el->logoutUser(array('id' => $this->modx->user->id, 'loginContext' => $properties['loginContext'], 'addContexts' => $properties['addContexts']))) { $this->modx->log(modX::LOG_LEVEL_ERROR, "[el] Could not logout for user: {$this->modx->user->id}"); } $linkLogin = $this->el->getLink('login', $properties); $linkLogout = $this->el->getLink('logout', $properties); $array = array('process' => array('id' => $this->modx->user->id, 'type' => 'user', 'output' => $this->el->processSnippet(array_merge($properties, array('id' => 0)))), 'properties' => array('link_login' => $linkLogin, 'link_logout' => $linkLogout)); return $this->success($this->el->lexicon('logout_success'), $array); }
/** {@inheritDoc} */ public function process() { $email = $this->getProperty('email'); if (empty($email)) { return $this->el->failure($this->el->lexicon('err_email_ns')); } $propKey = $this->getProperty('propkey'); if (empty($propKey)) { return $this->el->failure($this->el->lexicon('err_propkey_ns')); } $properties = $this->el->getProperties($propKey); if (empty($properties)) { return $this->el->failure($this->el->lexicon('err_properties_ns')); } $userId = $this->el->getUserId($email); if (empty($userId)) { $locked = $this->el->addLock(array('key' => 'email', 'id' => session_id()), array('ttlLock' => $properties['ttlLock'])); if ($locked !== true) { return $this->el->failure($this->el->lexicon('err_limit_action')); } $create = $this->el->createUser(array('email' => $email, 'groups' => $properties['groups'])); if (!$create) { return $this->el->failure($this->el->lexicon('err_create_user')); } $userId = $this->el->getUserId($email); } $hash = $this->el->getHash(array('id' => $userId)); $locked = $this->el->addLock(array('key' => 'link', 'id' => $hash, 'user' => $userId, 'properties' => $properties), array('ttlLock' => $properties['ttlLink'])); if ($locked !== true) { return $this->el->failure($this->el->lexicon('err_login_link_send')); } $linkLogin = $this->el->getLink('login', $properties, array('email' => $email, 'hash' => $hash)); $linkLogout = $this->el->getLink('logout', $properties); if (!$this->el->sendEmail(array('user' => $userId, 'body' => $this->modx->getChunk($properties['tplLink'], array_merge($this->el->getUserData($userId), array('link_login' => $linkLogin, 'link_logout' => $linkLogout)))))) { return $this->el->failure($this->el->lexicon('err_email_send', array('errors' => $this->modx->mail->mailer->errorInfo))); } $locked = $this->el->addLock(array('key' => 'send', 'id' => session_id()), array('ttlLock' => $properties['ttlLink'])); if ($locked !== true) { return $this->el->failure($this->el->lexicon('err_login_link_send')); } $array = array('process' => array('id' => '0', 'type' => 'user', 'output' => $this->el->processSnippet($properties)), 'properties' => array()); return $this->success($this->el->lexicon('login_link_send'), $array); }