当前位置: 首页>>代码示例>>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;未经允许,请勿转载。