本文整理汇总了PHP中sfGuardUser类的典型用法代码示例。如果您正苦于以下问题:PHP sfGuardUser类的具体用法?PHP sfGuardUser怎么用?PHP sfGuardUser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了sfGuardUser类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: registerUser
private function registerUser($username, $data = NULL)
{
try {
$gingerKey = sfConfig::get('app_portail_ginger_key');
if ($gingerKey != "abc") {
$ginger = new \Ginger\Client\GingerClient(sfConfig::get('app_portail_ginger_key'));
$cotisants = $ginger->getUser($username);
} else {
$cotisants = new stdClass();
$cotisants->mail = $username . "@etu.utc.fr";
$cotisants->prenom = "Le";
$cotisants->nom = "Testeur";
$cotisants->type = "etu";
}
if (!$data) {
$data = new sfGuardUser();
}
$data->setUsername($username);
$data->setEmailAddress($cotisants->mail);
$data->setFirstName($cotisants->prenom);
$data->setLastName($cotisants->nom);
$data->setIsActive(true);
$data->save();
$profile = new Profile();
$profile->setUser($data);
$profile->setDomain($cotisants->type);
$profile->save();
return $data;
} catch (\Ginger\Client\ApiException $ex) {
$this->setFlash('error', "Il n'a pas été possible de vous identifier. Merci de contacter [email protected] en précisant votre login et le code d'erreur " . $ex->getCode() . ".");
}
return false;
}
开发者ID:TheoJD,项目名称:portail,代码行数:33,代码来源:sfUTCCASUser.class.php
示例17: executeRegister
/**
* executeRegister
*
* @access public
* @return void
*/
public function executeRegister(sfWebRequest $request)
{
$this->form = new sfGuardFormRegister();
if ($request->isMethod(sfRequest::POST)) {
$this->form->bind($request->getParameter($this->form->getName()));
if ($this->form->isValid()) {
$values = $this->form->getValues();
$sfGuardUser = new sfGuardUser();
$sfGuardUser->fromArray($values, BasePeer::TYPE_FIELDNAME);
if (isset($values['email'])) {
$sfGuardUser->setEmail($values['email']);
}
$sfGuardUser->setIsActive(false);
$sfGuardUser->save();
$messageParams = array('sfGuardUser' => $sfGuardUser, 'password' => $values['password']);
$body = $this->getComponent($this->getModuleName(), 'send_request_confirm', $messageParams);
$from = sfConfig::get('app_sf_guard_extra_plugin_mail_from', '[email protected]');
$fromName = sfConfig::get('app_sf_guard_extra_plugin_name_from', 'noreply');
$to = $sfGuardUser->getEmail();
$toName = $sfGuardUser->getUsername();
$subject = sfConfig::get('app_sf_guard_extra_plugin_subject_confirm', 'Confirm Registration');
$mailer = $this->getMailer();
$message = $mailer->compose(array($from => $fromName), array($to => $toName), $subject, $body);
$mailer->send($message);
$this->getUser()->setFlash('values', $values);
$this->getUser()->setFlash('sfGuardUser', $sfGuardUser);
return $this->redirect('@sf_guard_do_register');
}
}
}
开发者ID:lendji4000,项目名称:compose,代码行数:36,代码来源:BasesfGuardRegisterActions.class.php
示例18: createUser
public function createUser(array $guard_tab, $ei_user_tab)
{
$new_guard = new sfGuardUser();
$new_guard->setId($guard_tab['id']);
$new_guard->setUsername($guard_tab['username']);
$new_guard->setFirstName($guard_tab['first_name']);
$new_guard->setLastName($guard_tab['last_name']);
$new_guard->setEmailAddress($guard_tab['email_address']);
$new_guard->setPassword($guard_tab['password']);
$new_guard->save();
/* Création du EiUser */
EiUserTable::createUser($ei_user_tab, $new_guard->getId());
return $new_guard;
}
开发者ID:lendji4000,项目名称:compose,代码行数:14,代码来源:sfGuardUserTable.class.php
示例19: executeReactivate
public function executeReactivate(sfRequest $request)
{
$user = sfGuardUser::getUserByUsername($request->getParameter('username'));
if (!$user || $user->getIsActive()) {
return;
}
try {
// Create the mailer and message objects
$mailer = $this->getMailer();
// Render message parts
$profile = $user->getProfile();
$profile->setValidate('n' . self::createGuid());
$profile->save();
$mailContext = array('name' => $profile->getFullname(), 'validate' => $profile->getValidate());
$message = Swift_Message::newInstance();
$from = sfConfig::get('app_sfApplyPlugin_from');
$message->setFrom($from['email'], $from['fullname']);
$message->setTo($profile->getEmail(), $profile->getUser()->getUsername());
$message->setSubject(sfConfig::get('app_sfApplyPlugin_apply_subject', "Активация аккаунта на сайте " . $request->getHost()));
$message->setBody($this->getPartial('sfApply/sendValidateNew', $mailContext), 'text/html');
$message->addPart($this->getPartial('sfApply/sendValidateNewText', $mailContext), 'text/plain');
$mailer->send($message);
return 'After';
} catch (Exception $e) {
$mailer->disconnect();
$profile = $this->form->getObject();
$user = $profile->getUser();
$user->delete();
// You could re-throw $e here if you want to
// make it available for debugging purposes
return 'MailerError';
}
}
开发者ID:auphau,项目名称:joyreactor,代码行数:33,代码来源:BasesfApplyActions.class.php
示例20: signIn
/**
* Signs in the user on the application.
*
* @param sfGuardUser $user The sfGuardUser id
* @param boolean $remember Whether or not to remember the user
* @param Doctrine_Connection $con A Doctrine_Connection object
*/
public function signIn($user, $auth_key = null, $con = null)
{
// signin
$this->setApiUserid($user->getId());
$this->setAuthenticated(true);
$this->clearCredentials();
$this->addCredentials($user->getAllPermissionNames());
// save last login
$user->setLastLogin(date('Y-m-d H:i:s'));
$user->save($con);
// Set login messages
$message = array();
foreach ($user->getUndisplayedLoginMessages() as $message) {
$messages[] = $message->getMessage();
$message->setDisplayed(true);
$message->save();
}
if (count($message) > 0) {
$this->setFlash('login', $messages);
}
// remember?
if ($auth_key) {
$this->setApiAuthkey($auth_key);
$api_key = sfConfig::get('app_web_app_api_key');
$api = ApiKeyTable::getInstance()->findOneBy('api_key', $api_key);
$auth_key = sfGuardUserAuthKeyTable::getInstance()->getMostRecentValidByApiKeyIdAndAuthKey($api->getIncremented(), $auth_key);
$expires = strtotime($auth_key->getExpiresAt());
// make key as a cookie
$remember_cookie = sfConfig::get('app_sf_guard_plugin_remember_cookie_name', 'sfRemember');
sfContext::getInstance()->getResponse()->setCookie($remember_cookie, $auth_key->getAuthKey(), $expires);
}
}
开发者ID:nocoolnametom,项目名称:OpenMicNight,代码行数:39,代码来源:myUser.class.php
注:本文中的sfGuardUser类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论