本文整理汇总了PHP中sfGuardUser::setEmailAddress方法的典型用法代码示例。如果您正苦于以下问题:PHP sfGuardUser::setEmailAddress方法的具体用法?PHP sfGuardUser::setEmailAddress怎么用?PHP sfGuardUser::setEmailAddress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfGuardUser
的用法示例。
在下文中一共展示了sfGuardUser::setEmailAddress方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executeSignin
public function executeSignin($request)
{
$user = $this->getUser();
if ($user->isAuthenticated()) {
return $this->redirect('@homepage');
}
// Create SimpleSAML module
$simpleSAMLAuth = new SimpleSAML_Auth_Simple('default-sp');
// If the user is authenticated from the IdP
if ($simpleSAMLAuth->isAuthenticated()) {
$attributes = $simpleSAMLAuth->getAttributes();
// save the referer
$user_referer = $user->getReferer($request->getReferer());
// Try to find the user with his uid
$query = Doctrine_Core::getTable('sfGuardUser')->createQuery('u')->where('u.username = ?', $attributes['eduPersonPrincipalName'][0]);
// If the sGuardUser already exists in the database, it's OK
if ($query->count() >= 1) {
$guard_user = $query->fetchOne();
$guard_user->setEmailAddress($attributes['mail'][0]);
$guard_user->setLastName($attributes['cn'][0]);
$guard_user->save();
} else {
// the user doesn't exist, we create a new one with random password
$guard_user = new sfGuardUser();
$guard_user->setUsername($attributes['eduPersonPrincipalName'][0]);
$guard_user->setPassword(md5(microtime() . $attributes['eduPersonPrincipalName'][0] . mt_rand()));
$guard_user->setEmailAddress($attributes['mail'][0]);
$guard_user->setLastName($attributes['cn'][0]);
$guard_user->setIsActive(true);
$guard_user->save();
}
// Let the User signin
// The auth is not rembered : the IdP can decide that
$this->getUser()->signin($guard_user, $remember = false);
// always redirect to a URL set in app.yml
// or to the referer
// or to the homepage
$signinUrl = sfConfig::get('app_sf_guard_plugin_success_signin_url', $user_referer);
return $this->redirect('' != $signinUrl ? $signinUrl : '@homepage');
} else {
if ($request->isXmlHttpRequest()) {
$this->getResponse()->setHeaderOnly(true);
$this->getResponse()->setStatusCode(401);
return sfView::NONE;
}
// if we have been forwarded, then the referer is the current URL
// if not, this is the referer of the current request
$user->setReferer($this->getContext()->getActionStack()->getSize() > 1 ? $request->getUri() : $request->getReferer());
/* gyufi $this->url_idp = $simpleSAMLAuth->login(array(
//'saml:idp' => 'https://openidp.feide.no',
'saml:idp' => 'https://aai.sztaki.hu/idp-partners',
'saml:idp' => 'https://aai.sztaki.hu/idp',
));
*/
$this->url_idp = $simpleSAMLAuth->login();
// Nothing happened after there, $simpleSAMLAuth->login() calls exit()
/*
$module = sfConfig::get('sf_login_module');
if ($this->getModuleName() != $module)
{
return $this->redirect($module.'/'.sfConfig::get('sf_login_action'));
}
$this->getResponse()->setStatusCode(401);
*/
}
}
示例2: 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 simde@assos.utc.fr en précisant votre login et le code d'erreur " . $ex->getCode() . ".");
}
return false;
}
示例3: testSavingBlockedUser
/**
* Tests saving a sfGuardUserSubredditMembership that identifies a User as
* "blocked" for a particular Subreddit. When this occurs, all existing
* future EpisodeAssignments should be deleted because blocked users cannot
* participate with the Subreddit.
*/
public function testSavingBlockedUser()
{
// Establish fake Subreddit
$subreddit = new Subreddit();
$subreddit->setName(rand(0, 1000));
$subreddit->setDomain(rand(0, 1000));
$subreddit->save();
// Establish User
$user = new sfGuardUser();
$user->setEmailAddress(rand(0, 100000));
$user->setUsername(rand(0, 10000));
$user->setIsValidated(1);
$user->save();
$user_id = $user->getIncremented();
$this->assertNotEquals(0, $user_id);
// Establish Episode for Subreddit
$episode = new Episode();
$episode->setSubreddit($subreddit);
$episode->setReleaseDate(date('Y-m-d H:i:s', time() + 34000));
$episode->save();
$author_type = AuthorTypeTable::getInstance()->findOneBy('type', 'squid');
$deadline = new Deadline();
$deadline->setSubreddit($subreddit);
$deadline->setAuthorType($author_type);
$deadline->setSeconds(0);
$deadline->save();
$episode_assignment = new EpisodeAssignment();
$episode_assignment->setSfGuardUser($user);
$episode_assignment->setEpisode($episode);
$episode_assignment->setAuthorType($author_type);
$episode_assignment->save();
$number_of_episodes = EpisodeAssignmentTable::getInstance()->createQuery()->select('COUNT(EpisodeAssignment.id)')->leftJoin('Episode')->where('subreddit_id = ?', $subreddit->getIncremented())->andWhere('EpisodeAssignment.sf_guard_user_id = ?', $user_id)->andWhere('Episode.release_date > NOW()')->groupBy('EpisodeAssignment.id')->count();
$this->assertEquals(1, $number_of_episodes);
// Establish User Membership as Blocked
$blocked = MembershipTable::getInstance()->findOneBy('type', 'blocked');
$user_membership = new sfGuardUserSubredditMembership();
$user_membership->setSubreddit($subreddit);
$user_membership->setSfGuardUser($user);
$user_membership->setMembership($blocked);
// Save Membership
$user_membership->save();
// Asert that User has zero Episodes
$number_of_episodes = EpisodeAssignmentTable::getInstance()->createQuery()->select('COUNT(EpisodeAssignment.id)')->leftJoin('Episode')->where('subreddit_id = ?', $subreddit->getIncremented())->andWhere('EpisodeAssignment.sf_guard_user_id = ?', $user_id)->andWhere('Episode.release_date > NOW()')->groupBy('EpisodeAssignment.id');
$sql = $number_of_episodes->getSqlQuery();
$number_of_episodes = $number_of_episodes->count();
$this->assertTrue(0 == $number_of_episodes, $sql . "\n" . $subreddit->getIncremented() . "\n" . $user_id);
// Remove User Membership
$user_membership->delete();
// Delete User
$user->delete();
// Delete Episode
$episode->delete();
// Delete Deadline
$deadline->delete();
// Delete Subreddit
$subreddit->delete();
}
示例4: doSave
public function doSave($con = null)
{
$user = new sfGuardUser();
$user->setUsername($this->getValue('username'));
$user->setPassword($this->getValue('password'));
$user->setEmailAddress($this->getValue('email'));
// They must confirm their account first
$user->setIsActive(false);
$user->save();
$this->userId = $user->getId();
return parent::doSave($con);
}
示例5: 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');
}
示例6: 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;
}
示例7: execute
/**
* @see sfTask
*/
protected function execute($arguments = array(), $options = array())
{
$databaseManager = new sfDatabaseManager($this->configuration);
$user = new sfGuardUser();
$user->setEmailAddress($arguments['email_address']);
$user->setUsername($arguments['username']);
$user->setPassword($arguments['password']);
$user->setFirstName($arguments['first_name']);
$user->setLastName($arguments['last_name']);
$user->setIsActive(true);
$user->setIsSuperAdmin($options['is-super-admin']);
$user->save();
$this->logSection('guard', sprintf('Create user "%s"', $arguments['username']));
}
示例8: doSave
public function doSave($con = null)
{
if ($this->isNew) {
$user = new sfGuardUser();
$user->setUsername($this->getValue('username'));
$user->setPassword($this->getValue('password'));
$user->setEmailAddress($this->getValue('email'));
$user->addGroupByName(sfConfig::get('app_user_default_group'));
// They must confirm their account first
$user->setIsActive(false);
$user->save();
$this->getObject()->setUserId($user->getId());
}
return parent::doSave($con);
}
示例9: updateOrCreateUser
/**
* Updates or creates a sfGuardUser for the logged in Facebook usser
*
* @param array $me
* @return sfGuardUser
*/
public static function updateOrCreateUser(array $me) {
// Try by Facebook ID
$sfGuardUser = Doctrine_Core::getTable('sfGuardUser')->findOneByFacebookId($me['id']);
if (!$sfGuardUser) {
// Try by email address
$sfGuardUser = Doctrine_Core::getTable('sfGuardUser')->findOneByEmailAddress($me['email']);
if (!$sfGuardUser) {
$sfGuardUser = new sfGuardUser();
$sfGuardUser->setUsername('Facebook_' . $me['id']);
}
}
$sfGuardUser->setFacebookId($me['id']);
$sfGuardUser->setFacebookLink($me['link']);
$sfGuardUser->setFirstName($me['first_name']);
$sfGuardUser->setLastName($me['last_name']);
if (array_key_exists('verified', $me)) {
$sfGuardUser->setFacebookVerified($me['verified']);
}
if (array_key_exists('location', $me)) {
$sfGuardUser->setLocation($me['location']['name']);
$sfGuardUser->setFacebookLocationId($me['location']['id']);
}
if (array_key_exists('hometown', $me)) {
$sfGuardUser->setHometown($me['hometown']['name']);
$sfGuardUser->setFacebookHometownId($me['hometown']['id']);
}
$sfGuardUser->setGender($me['gender']);
$sfGuardUser->setLocale($me['locale']);
$sfGuardUser->setTimezone($me['timezone']);
if (array_key_exists('email', $me)) {
$sfGuardUser->setEmailAddress($me['email']);
}
$sfGuardUser->save();
return $sfGuardUser;
}
开发者ID:rosbif-fr,项目名称:kdDoctrineGuardFacebookConnectPlugin,代码行数:43,代码来源:kdDoctrineGuardFacebookConnect.class.php
示例10: processForm
protected function processForm(sfWebRequest $request, sfForm $form)
{
$form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
if ($form->isValid()) {
$peticion = $form->save();
$newUser = new sfGuardUser();
$newUser->setUsername($form->getObject()->getUsername());
$newUser->setFirstName($form->getObject()->getFirstName());
$newUser->setLastName($form->getObject()->getLastName());
$newUser->setSexo($form->getObject()->getSexo());
$newUser->setDireccion($form->getObject()->getDireccion());
$newUser->setTelefono($form->getObject()->getTelefono());
$newUser->setTelefonoMovil($form->getObject()->getTelefonoMovil());
$newUser->setEmailAddress($form->getObject()->getEmailAddress());
$newUser->setPassword($form->getObject()->getPassword());
try {
$newUser->save();
$peticion->delete();
$this->redirect('sfGuardUser/editagregar?id=' . $newUser->getId());
} catch (Exception $e) {
$this->redirect('peticion/edit?id=' . $peticion->getId());
}
}
}
示例11: testGetFirstByUserSubredditAndMemberships
/**
* Since a User can only have one membership in a Subreddit, this tests that
* the first returned sfGuardUserSubredditMembership is the exact same as
* the only one made. The limitation on sfGuardUserSubredditMemberships is
* in place using Unique indexes in the database, so we depend upon that to
* prevent multiple Subreddit Memberships.
*/
public function testGetFirstByUserSubredditAndMemberships()
{
$user = new sfGuardUser();
$user->setEmailAddress(rand(0, 1000));
$user->setUsername(rand(0, 1000));
$user->setIsValidated(1);
$user->save();
$subreddit = new Subreddit();
$subreddit->setName(rand(0, 1000));
$subreddit->setDomain(rand(0, 1000));
$subreddit->save();
$membership = MembershipTable::getInstance()->findOneByType('user');
$second_membership = MembershipTable::getInstance()->findOneByType('admin');
$user_subreddit_membership = new sfGuardUserSubredditMembership();
$user_subreddit_membership->setSfGuardUserId($user->getIncremented());
$user_subreddit_membership->setSubredditId($subreddit->getIncremented());
$user_subreddit_membership->setMembership($membership);
$user_subreddit_membership->save();
$second_user_subreddit_membership = new sfGuardUserSubredditMembership();
$second_user_subreddit_membership->setSfGuardUserId($user->getIncremented());
$second_user_subreddit_membership->setSubredditId($subreddit->getIncremented());
$second_user_subreddit_membership->setMembership($second_membership);
$exception_thrown = false;
try {
$second_user_subreddit_membership->save();
} catch (Exception $exception) {
unset($exception);
$exception_thrown = true;
}
$retrieved_object = sfGuardUserSubredditMembershipTable::getInstance()->getFirstByUserSubredditAndMemberships($user->getIncremented(), $subreddit->getIncremented(), array($membership->getType()));
$this->assertEquals($retrieved_object->getIncremented(), $user_subreddit_membership->getIncremented());
$user_subreddit_membership->delete();
$subreddit->delete();
$user->delete();
$this->assertTrue($exception_thrown);
}
示例12: testdeleteWithException
/**
* We've combined the process for preventing saving with a specific call for
* deletion to aid in handling errors and dealing with unsaved objects.
* This tests whether the exception is thrown
*/
public function testdeleteWithException()
{
$subreddit = new Subreddit();
$subreddit->setName(rand(0, 10000));
$subreddit->setDomain(rand(0, 10000));
$subreddit->save();
$user = new sfGuardUser();
$user->setUsername(rand(0, 10000));
$user->setEmailAddress(rand(0, 10000));
$user->setIsValidated(1);
$user->save();
$first = AuthorTypeTable::getInstance()->findOneByType('squid');
$episode = new Episode();
$episode->setReleaseDate(date('Y-m-d H:i:s', time() + 100000));
$episode->setSubreddit($subreddit);
$episode->save();
$deadline = new Deadline();
$deadline->setSubreddit($subreddit);
$deadline->setAuthorType($first);
$deadline->setSeconds(0);
$deadline->save();
$assignment = new EpisodeAssignment();
$assignment->setSfGuardUser($user);
$assignment->setEpisode($episode);
$assignment->setAuthorType($first);
$assignment->save();
// Delete with exception
$exception_thrown = false;
$exception_code = 987654321;
try {
$assignment->deleteWithException("Test exception", $exception_code);
} catch (sfException $exception) {
$this->assertEquals($exception_code, $exception->getCode());
unset($exception);
$exception_thrown = true;
}
$this->assertTrue($exception_thrown);
// Delete the rest of the objects
$episode->delete();
$user->delete();
$subreddit->delete();
}
示例13: processOrganizerForm
protected function processOrganizerForm(sfWebRequest $request, sfForm $form)
{
//$form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
if ($form->isValid()) {
//$form->save();
$name = $form->getValue('name');
$email = $form->getValue('email');
//$colour = $form->getValue('colour_code');
$guard_user = new sfGuardUser();
$guard_user->setEmailAddress($email);
$guard_user->setUsername($email);
$guard_user->setPassword($form->getValue('password'));
$guard_user->setIsActive(1);
$guard_user->save();
$organizer = new Organizer();
$organizer->setName($name);
$organizer->setSfGuardId($guard_user->getId());
//$organizer->setColourCode($colour);
$organizer->save();
$this->redirect('organize/new');
}
}
示例14: processLdap
/**
*
* @param sfWebRequest $request
* @param LdapForm $form
*/
protected function processLdap(sfWebRequest $request, LdapForm $form)
{
$form->bind($request->getParameter('signin'));
if ($form->isValid()) {
$values = $form->getValues();
// Check if user already exists in the DB
$user = Doctrine::getTable('sfGuardUser')->findOneByUsername($values["username"]);
// If not, create an account for him
if (empty($user)) {
$datetime = date("Y-m-d H:i:s");
// Create entry in sfGuardUser
$sfGuardUser = new sfGuardUser();
$sfGuardUser->setEmailAddress($values["username"]);
$sfGuardUser->setUsername($values["username"]);
$sfGuardUser->setFirstName($values["firstname"]);
$sfGuardUser->setLastName($values["lastname"]);
$sfGuardUser->setCreatedAt($datetime);
$sfGuardUser->setUpdatedAt($datetime);
$sfGuardUser->save();
// Additional informations for user's profile
$sfGuardUserProfile = new sfGuardUserProfile();
$sfGuardUserProfile->setUserId($sfGuardUser->getId());
$sfGuardUserProfile->setToken(MiscUtils::generateToken());
$sfGuardUserProfile->setSecurityLevel(sfConfig::get("app_security_level_new_user", 0));
$sfGuardUserProfile->save();
$permission = Doctrine_Core::getTable("sfGuardPermission")->findOneByName(sfConfig::get("app_permission_new_user", "User"));
if (!$permission) {
$this->getUser()->setFlash("error", "Unable to set permissions for this account! Contact your administrator.");
$sfGuardUserProfile->delete();
$sfGuardUser->delete();
return;
}
// Give basic permissions for user
$sfGuardPermission = new sfGuardUserPermission();
$sfGuardPermission->setUserId($sfGuardUser->getId());
$sfGuardPermission->setPermissionId($permission->getId());
$sfGuardPermission->setCreatedAt($datetime);
$sfGuardPermission->setUpdatedAt($datetime);
$sfGuardPermission->save();
$userGroup = Doctrine_Core::getTable("sfGuardGroup")->findOneByName(sfConfig::get("app_project_group"));
if (!$userGroup) {
$this->getUser()->setFlash("error", "Unable to set project group for this account! Contact your administrator.");
$sfGuardUserProfile->delete();
$sfGuardUser->delete();
$sfGuardPermission->delete();
return;
}
// Create new entry into sfGuardUserGroup table
$sfGuardGroup = new sfGuardUserGroup();
$sfGuardGroup->setUserId($sfGuardUser->getId());
$sfGuardGroup->setGroupId($userGroup->getId());
$sfGuardGroup->setCreatedAt($datetime);
$sfGuardGroup->setUpdatedAt($datetime);
$sfGuardGroup->save();
$user = $sfGuardUser;
}
$this->getUser()->signIn($user, array_key_exists('remember', $values) ? $values['remember'] : false);
// Set the tow previous referer to the same value for:
// 1) redirect to previous user's location
// 2) avoid redirect loop in signin
$this->getUser()->setReferer($this->getUser()->getReferer());
// Redirect to referer
return $this->redirect($this->getUser()->getReferer());
}
}
示例15: mergeFacebookInfo
/**
* Merge a users data with that from Facebook, updating fields where
* appropriate
*
* @param array $facebookUserInfo
* @param sfGuardUser $user
* @return self
*/
public function mergeFacebookInfo(array $facebookUserInfo, sfGuardUser $user)
{
if (!$this->getUserSetName()) {
if (isset($facebookUserInfo['name']) && $this->getFullName() != $facebookUserInfo['name']) {
$this->setFullName($facebookUserInfo['name']);
}
if (isset($facebookUserInfo['first_name']) && $user->getFirstName() != $facebookUserInfo['first_name']) {
$user->setFirstName($facebookUserInfo['first_name']);
}
if (isset($facebookUserInfo['last_name']) && $user->getLastName() != $facebookUserInfo['last_name']) {
$user->setLastName($facebookUserInfo['last_name']);
}
}
if (!$this->getUserSetEmailAddress()) {
$email = isset($facebookUserInfo['email']) ? $facebookUserInfo['email'] : '';
if (sfConfig::get('app_facebook_dont_store_proxy_emails', false)) {
if (sfFacebookGraph::checkProxyEmail($email)) {
$email = '';
}
}
if ($email != $user->getEmailAddress()) {
$user->setEmailAddress($email);
}
}
return $this;
}
开发者ID:passkey1510,项目名称:sfFacebookGraphPlugin,代码行数:34,代码来源:PluginsfFacebookGraphUserProfile.class.php