當前位置: 首頁>>代碼示例>>PHP>>正文


PHP sfGuardUser類代碼示例

本文整理匯總了PHP中sfGuardUser的典型用法代碼示例。如果您正苦於以下問題:PHP sfGuardUser類的具體用法?PHP sfGuardUser怎麽用?PHP sfGuardUser使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了sfGuardUser類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: executeSignin

 public function executeSignin($request)
 {
     $this->form = new sfGuardFormSignin();
     if ($request->isMethod('post')) {
         $data = $request->getParameter('signin');
         $adldap = new adLDAP(array('account_suffix' => '@sch.bme.hu', 'domain_controllers' => array('152.66.208.42'), 'ad_username' => $data['username'], 'ad_password' => $data['password']));
         try {
             $authUser = $adldap->authenticate($data['username'], $data['password']);
             if ($authUser === true) {
                 $userData = $adldap->user_info($data['username']);
                 $user = Doctrine::getTable('sfGuardUser')->findOneBy('username', $data['username']);
                 $save = false;
                 if ($user) {
                     if ($user->Profile->full_name != $userData[0]["displayname"][0] || $user->Profile->email != $userData[0]["mail"][0]) {
                         $save = true;
                     }
                 } else {
                     $user = new sfGuardUser();
                     $save = true;
                 }
                 if ($save) {
                     $user->username = $data['username'];
                     $user->password = $data['password'];
                     $user->Profile->full_name = $userData[0]["displayname"][0];
                     $user->Profile->email = $userData[0]["mail"][0];
                     $user->save();
                 }
             }
         } catch (Exception $e) {
             echo $e;
         }
     }
     parent::executeSignin($request);
 }
開發者ID:szelpe,項目名稱:cukorka,代碼行數:34,代碼來源:actions.class.php

示例2: getUserMarkup

 static function getUserMarkup(sfGuardUser $user)
 {
     if (!$user->id) {
         throw new Exception("Can't get note markup for new user");
     }
     return '@' . $user->getProfile()->public_name;
 }
開發者ID:silky,項目名稱:littlesis,代碼行數:7,代碼來源:NoteTable.class.php

示例3: doClean

 /**
  * @see sfValidatorBase
  */
 protected function doClean($values)
 {
     // only validate if username and password are both present
     if (isset($values[$this->getOption('username_field')]) && isset($values[$this->getOption('password_field')])) {
         $username = $values[$this->getOption('username_field')];
         $password = $values[$this->getOption('password_field')];
         // user exists?
         if ($user = sfGuardUserPeer::retrieveByUsername($username)) {
             // password is ok?
             if ($user->getIsActive()) {
                 if (Configuration::get('ldap_enabled', false)) {
                     if (authLDAP::checkPassword($username, $password)) {
                         return array_merge($values, array('user' => $user));
                     }
                 } elseif ($user->checkPassword($password)) {
                     return array_merge($values, array('user' => $user));
                 }
             }
         } elseif (Configuration::get('ldap_enabled', false) && Configuration::get('ldap_create_user', false) && authLDAP::checkPassword($username, $password)) {
             $user = new sfGuardUser();
             $user->setUsername($username);
             $user->save();
             $profile = new Profile();
             $profile->setSfGuardUserId($user->getId());
             $profile->save();
             return array_merge($values, array('user' => $user));
         }
         if ($this->getOption('throw_global_error')) {
             throw new sfValidatorError($this, 'invalid');
         }
         throw new sfValidatorErrorSchema($this, array($this->getOption('username_field') => new sfValidatorError($this, 'invalid')));
     }
     // assume a required error has already been thrown, skip validation
     return $values;
 }
開發者ID:xfifix,項目名稱:Jenkins-Khan,代碼行數:38,代碼來源:ValidatorUser.class.php

示例4: executeSignup

 /**
  * Личные данные
  */
 public function executeSignup()
 {
     $loginzaData = $this->getUser()->getAttribute('loginza.identity', false, 'loginza');
     $this->forward404Unless($loginzaData);
     $user = new sfGuardUser();
     $user->fromArray($loginzaData);
     $this->form = new sfGuardUserForm($user);
 }
開發者ID:pycmam,項目名稱:neskuchaik.ru,代碼行數:11,代碼來源:actions.class.php

示例5: isSelfUser

 /**
  *
  * @param sfGuardUser $user or User ID
  * @return boolean
  * @throws Exception
  */
 public function isSelfUser($user)
 {
     if ($user instanceof sfGuardUser) {
         return $this->getGuardUser()->getId() == $user->getId();
     } elseif (is_numeric($user)) {
         return $user == $this->getGuardUser()->getId();
     }
     throw new Exception('wrong argument');
 }
開發者ID:uniteddiversity,項目名稱:policat,代碼行數:15,代碼來源:policatActions.class.php

示例6: checkIfImInList

 public static final function checkIfImInList(sfGuardUser $me, Doctrine_Collection $usersCollection)
 {
     foreach ($usersCollection as $user) {
         if ($user->getId() === $me->getId()) {
             return true;
         }
     }
     return false;
 }
開發者ID:vik0803,項目名稱:helpdesk,代碼行數:9,代碼來源:Helpdesk.class.php

示例7: execute

 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     $databaseManager = new sfDatabaseManager($this->configuration);
     $user = new sfGuardUser();
     $user->setUsername($arguments['username']);
     $user->setPassword($arguments['password']);
     $user->save();
     $this->logSection('guard', sprintf('Create user "%s"', $arguments['username']));
 }
開發者ID:ketheriel,項目名稱:ETVA,代碼行數:12,代碼來源:sfGuardCreateUserTask.class.php

示例8: getOrCreateUserByEmail

 /**
  * Gets or creates an sfGuardUser record by email
  * 
  * The password and any other information is auto-generated in sfGuardUser
  */
 public function getOrCreateUserByEmail($email)
 {
     $guardUser = $this->findOneByEmailAddress($email);
     if (!$guardUser) {
         $guardUser = new sfGuardUser();
         $guardUser->username = $email;
         $guardUser->save();
     }
     return $guardUser;
 }
開發者ID:bshaffer,項目名稱:Donate-Nashville,代碼行數:15,代碼來源:sfGuardUserTable.class.php

示例9: execute

 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     $configuration = ProjectConfiguration::getApplicationConfiguration($arguments['application'], $options['env'], true);
     $databaseManager = new sfDatabaseManager($configuration);
     $user = new sfGuardUser();
     $user->setUsername($arguments['username']);
     $user->setPassword($arguments['password']);
     $user->setIsActive(true);
     $user->save();
     $this->logSection('guard', sprintf('Create user "%s"', $arguments['username']));
 }
開發者ID:silky,項目名稱:littlesis,代碼行數:14,代碼來源:sfGuardCreateUserTask.class.php

示例10: queryByMember

 /**
  *
  * @param sfGuardUser $user
  * @return Doctrine_Query
  */
 public function queryByMember(sfGuardUser $user, $is_member = true, $deleted_too = false)
 {
     if ($user->hasPermission(myUser::CREDENTIAL_ADMIN)) {
         return $this->queryAll($deleted_too);
     }
     if ($is_member) {
         return $this->queryAll($deleted_too)->innerJoin('c.CampaignRights cr')->andWhere('cr.user_id = ? AND cr.active = ?', array($user->getId(), 1));
     } else {
         return $this->queryAll($deleted_too)->andWhere('c.id NOT IN (SELECT cr.campaign_id FROM CampaignRights cr WHERE cr.user_id = ? AND cr.active = ?)', array($user->getId(), 1));
     }
 }
開發者ID:uniteddiversity,項目名稱:policat,代碼行數:16,代碼來源:CampaignTable.class.php

示例11: executeCreateUser

 public function executeCreateUser(sfWebRequest $request)
 {
     $data = $request->getPostParameter('data');
     $user = new sfGuardUser();
     $user->username = $data['username'];
     $user->password = $data['password'];
     $user->save();
     $this->setTemplate('showUsers');
     //    $this->settings = Doctrine_Core::getTable('Settings')->findOneById(1);
     //    echo $this->getUser()->getGuardUser()->getUsername();
     //        $this->forward404Unless($this->settings);
 }
開發者ID:nass600,項目名稱:homeCENTER,代碼行數:12,代碼來源:actions.class.php

示例12: newPerson

 public function newPerson($name)
 {
     // Creating sfGuardUser
     $guardUser = new sfGuardUser();
     $guardUser->set('name', $name);
     $guardUser->save();
     // Creating the Person
     $person = new Person();
     $person->set('name', $name);
     $person->set('sf_guard_user_id', $guardUser['id']);
     $person->save();
     return $person;
 }
開發者ID:dennybrandes,項目名稱:doctrine1,代碼行數:13,代碼來源:876TestCase.php

示例13: executeFacebookLogin

 /**
  * Accepts proof of identity from the client side Facebook SDK.
  * https://developers.facebook.com/docs/howtos/login/signed-request/#step2
  * This will not work if your site doesn't have a proper
  * domain name (it will not work in dev, in most cases).
  */
 public function executeFacebookLogin(sfWebRequest $request)
 {
     $fb = sfConfig::get('app_sfApplyPlugin_facebook');
     $secret = isset($fb['secret']) ? $fb['secret'] : null;
     if (!$secret) {
         throw new sfException('app_sfApplyPlugin_facebook not configured, secret missing');
     }
     $signed_request = $request->getParameter('signed_request');
     list($encoded_sig, $payload) = explode('.', $signed_request, 2);
     // decode the data
     $sig = $this->base64UrlDecode($encoded_sig);
     $data = json_decode($this->base64UrlDecode($payload), true);
     // Contrary to FB docs we're not done yet, we have to
     // trade the 'code' in for an access token and then we
     // can query for information about the user
     $code = $data['code'];
     $url = "https://graph.facebook.com/oauth/access_token?" . http_build_query(array('client_id' => $fb['id'], 'redirect_uri' => '', 'client_secret' => $secret, 'code' => $code));
     $accessToken = file_get_contents($url);
     parse_str($accessToken, $result);
     $accessToken = $result['access_token'];
     $me = json_decode(file_get_contents("https://graph.facebook.com/me?" . http_build_query(array('access_token' => $accessToken))), true);
     if (!isset($me['email'])) {
         $this->forward404();
     }
     $email = $me['email'];
     $first_name = $me['first_name'];
     $last_name = $me['last_name'];
     $username = 'fb_' . (isset($me['username']) ? $me['username'] : $me['id']);
     if (strtoupper($data['algorithm']) !== 'HMAC-SHA256') {
         $this->forward404();
     }
     // Adding the verification of the signed_request below
     $expected_sig = hash_hmac('sha256', $payload, $secret, $raw = true);
     if ($sig !== $expected_sig) {
         $this->forward404();
     }
     $user = Doctrine::getTable('sfGuardUser')->findOneByEmailAddress($email);
     if (!$user) {
         $user = new sfGuardUser();
         $user->setIsActive(true);
         $user->setPassword(aGuid::generate());
         $user->setEmailAddress($email);
         $user->setUsername($username);
     }
     $user->setFirstName($firstName);
     $user->setLastName($lastName);
     $user->setEmailAddress($email);
     $user->save();
     $this->getUser()->signIn($user);
     return $this->renderText('OK');
 }
開發者ID:alex1818,項目名稱:TestReportCenter,代碼行數:57,代碼來源:BasesfApplyActions.class.php

示例14: validaAsignacion

 /**
  * Verifica los datos para realizar la asignación.
  * @param sfGuardUser $lider
  * @param sfGuardUser $discipulo
  * @param type $actualizacion
  * @param type $correo
  * @return string 
  */
 private function validaAsignacion(sfGuardUser $lider, sfGuardUser $discipulo, $actualizacion, $correo = null)
 {
     $resultado = 'ok';
     if ($lider->getGenero() != $discipulo->getGenero()) {
         $resultado = "Los géneros del Líder y del Discípulo no coinciden";
     }
     if ($actualizacion != 'ok') {
         $resultado = "Error al actualizar discipulo: " . $actualizacion;
     }
     if ($correo && ($correo <= 0 || is_nan($correo)) && sfConfig::get('app_envia_mails')) {
         $resultado = "Error al enviar el correo: " . $correo;
     }
     return $resultado;
 }
開發者ID:laiello,項目名稱:tesiscdfeg12,代碼行數:22,代碼來源:actions.class.php

示例15: execute

 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     $databaseManager = new sfDatabaseManager($this->configuration);
     $user = new sfGuardUser();
     $user->setUsername($arguments['username']);
     $user->setPassword($arguments['password']);
     $user->save();
     $profile = new Profile();
     $profile->setNickname($arguments['nickname']);
     $profile->setEmail($arguments['email']);
     $profile->setSfGuardUserId($user->getId());
     $profile->save();
     $this->logSection('crew', sprintf('Create user "%s"', $arguments['username']));
 }
開發者ID:ratibus,項目名稱:Crew,代碼行數:17,代碼來源:createUserTask.class.php


注:本文中的sfGuardUser類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。