本文整理汇总了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);
}
示例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;
}
示例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;
}
示例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);
}
示例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');
}
示例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;
}
示例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']));
}
示例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;
}
示例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']));
}
示例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));
}
}
示例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);
}
示例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;
}
示例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');
}
示例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;
}
示例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']));
}