public function sendMail()
 {
     $token = md5(opToolkit::generatePasswordString());
     $this->member->setConfig('password_recovery_token', $token);
     $params = array('token' => $token, 'id' => $this->member->id, 'subject' => '【' . opConfig::get('sns_name') . '】パスワード再設定用URL発行のお知らせ');
     sfOpenPNEMailSend::sendTemplateMail('passwordRecovery', $this->member->getEMailAddress(), opConfig::get('admin_mail_address'), $params);
 }
 public function preSave($event)
 {
     if (!$this->exists()) {
         $this->key_string = opToolkit::generatePasswordString(16, false);
         $this->secret = opToolkit::generatePasswordString(32);
     }
 }
 public function new_access_token($token, $consumer)
 {
     $information = Doctrine::getTable('OAuthConsumerInformation')->findByKeyString($consumer->key);
     if ($information) {
         $key = opToolkit::generatePasswordString(16, false);
         $secret = opToolkit::generatePasswordString(32, false);
         $tokenRecord = $this->queryTemplate->andWhere('oauth_consumer_id = ?', $information->id)->andWhere('type = ?', 'access')->fetchOne();
         if (!$tokenRecord) {
             $tokenRecord = $this->recordTemplate;
         }
         $tokenRecord->setKeyString($key);
         $tokenRecord->setSecret($secret);
         $tokenRecord->setConsumer($information);
         $tokenRecord->setType('access');
         $tokenRecord->save();
         return new OAuthToken($key, $secret);
     }
     return null;
 }
 /**
  * Executes update consumer secret
  *
  * @param sfWebRequest $request
  */
 public function executeUpdateConsumerSecret(sfWebRequest $request)
 {
     if ($request->isMethod(sfWebRequest::POST)) {
         if (!$this->application->getConsumerKey()) {
             $this->application->setConsumerKey(opToolkit::generatePasswordString(16, false));
         }
         $this->application->setConsumerSecret(opToolkit::generatePasswordString(32));
         $this->application->save();
         $this->redirect('@op_opensocial_info?id=' . $this->application->getId());
     }
     return sfView::INPUT;
 }
Example #5
0
 /**
  * set remember login cookie
  */
 protected function setRememberLoginCookie($isDeleteCookie = false)
 {
     $key = md5(sfContext::getInstance()->getRequest()->getHost());
     $path = sfContext::getInstance()->getRequest()->getRelativeUrlRoot();
     if (!$path) {
         $path = '/';
     }
     if ($isDeleteCookie) {
         if (!sfContext::getInstance()->getRequest()->getCookie($key)) {
             return;
         }
         if ($this->getMemberId()) {
             $this->getMember()->setConfig('remember_key', '');
         }
         $value = null;
         $expire = time() - 3600;
     } else {
         $rememberKey = opToolkit::generatePasswordString();
         if (!$this->getMemberId()) {
             throw new LogicException('No login');
         }
         $this->getMember()->setConfig('remember_key', $rememberKey);
         $value = base64_encode(serialize(array($this->getMemberId(), $rememberKey)));
         $expire = time() + sfConfig::get('op_remember_login_limit', 60 * 60 * 24 * 30);
     }
     sfContext::getInstance()->getResponse()->setCookie($key, $value, $expire, $path, '', false, true);
 }
 public function save()
 {
     $member = $this->memberForm->save();
     $this->setMember($member);
     $profile = $this->profileForm->save($this->getMember()->getId());
     $config = $this->configForm->save($this->getMember()->getId());
     $auth = $this->doSave();
     if ($member && $profile && $auth && $config) {
         if ($this->getValue('mobile_uid')) {
             $this->getMember()->setConfig('mobile_uid', $this->getValue('mobile_uid'));
         }
         $communities = Doctrine::getTable('Community')->getDefaultCommunities();
         foreach ($communities as $community) {
             Doctrine::getTable('CommunityMember')->join($this->getMember()->getId(), $community->getId());
         }
         if (sfConfig::get('op_is_mail_address_contain_hash')) {
             $str = opToolkit::generatePasswordString(sfConfig::get('op_mail_address_hash_length', 12), false);
             $this->getMember()->setConfig('mail_address_hash', strtolower($str));
         }
         return $this->getMember()->getId();
     }
     return false;
 }
 /**
  * Executes update consumer secret
  *
  * @param sfWebRequest $request
  */
 public function executeUpdateConsumerSecret(sfWebRequest $request)
 {
     $this->forward404Unless($this->member->getId() === $this->application->getMemberId());
     if ($request->isMethod(sfWebRequest::POST)) {
         if (!$this->application->getConsumerKey()) {
             $this->application->setConsumerKey(opToolkit::generatePasswordString(16, false));
         }
         $this->application->setConsumerSecret(opToolkit::generatePasswordString(32));
         $this->application->save();
         $this->redirect('@application_info?id=' . $this->application->getId());
     }
     return sfView::INPUT;
 }
 /**
  * Executes update backend consumer secret
  *
  * @param sfWebRequest $request
  */
 public function executeUpdateBackendConsumerSecret(sfWebRequest $request)
 {
     if ($request->isMethod(sfWebRequest::POST)) {
         $request->checkCSRFProtection();
         $snsConfigTable = Doctrine::getTable('SnsConfig');
         if (!$snsConfigTable->get('shindig_backend_key')) {
             $snsConfigTable->set('shindig_backend_key', opToolkit::generatePasswordString(16, false));
         }
         $snsConfigTable->set('shindig_backend_secret', opToolkit::generatePasswordString(32));
         $this->redirect('@op_opensocial_container_config');
     }
     return sfView::INPUT;
 }