本文整理汇总了PHP中sfGuardUser::setPassword方法的典型用法代码示例。如果您正苦于以下问题:PHP sfGuardUser::setPassword方法的具体用法?PHP sfGuardUser::setPassword怎么用?PHP sfGuardUser::setPassword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfGuardUser
的用法示例。
在下文中一共展示了sfGuardUser::setPassword方法的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: doClean
protected function doClean($values)
{
$username = isset($values[$this->getOption('username_field')]) ? $values[$this->getOption('username_field')] : '';
bhLDAP::debug('######## Username: ' . $username);
$password = isset($values[$this->getOption('password_field')]) ? $values[$this->getOption('password_field')] : '';
bhLDAP::debug('######## User exists?');
$user = Doctrine::getTable('sfGuardUser')->findOneByUsername($username);
// bhLDAP::debugDump($user, "user:");
if (!$user) {
if (bhLDAP::checkPassword($username, $password)) {
// pretend the user exists, then check AD password
bhLDAP::debug('######## User does not exist. Creating dummy user.');
$user = new sfGuardUser();
$user->setUsername($username);
$user->setSalt('unused');
$user->setPassword('unused');
$user->setUserProfile(new UserProfile());
$user->save();
}
return array_merge($values, array('user' => $user));
}
// password is ok?
bhLDAP::debug('######## Checking Password...');
if ($user->checkPassword($password)) {
bhLDAP::debug('######## Check Password successful...');
return array_merge($values, array('user' => $user));
}
bhLDAP::debug('######## Check Password failed...');
if ($this->getOption('throw_global_error')) {
throw new sfValidatorError($this, 'invalid');
}
throw new sfValidatorErrorSchema($this, array($this->getOption('username_field') => new sfValidatorError($this, 'invalid')));
}
示例3: 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']));
}
示例4: doSave
public function doSave($con = null)
{
$user = new sfGuardUser();
$user->setUsername($this->getValue('username'));
$user->setPassword($this->getValue('password'));
// They must confirm their account first
$user->setIsActive(false);
$user->save();
$this->userId = $user->getId();
return parent::doSave($con);
}
示例5: 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']));
}
示例6: 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');
}
示例7: 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;
}
示例8: 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']));
}
示例9: 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']));
}
示例10: 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);
}
示例11: executeApply
public function executeApply()
{
$request = $this->getRequest();
$this->form = new RegisterForm();
if ($this->getRequest()->getMethod() == sfRequest::POST) {
$this->form->bind($request->getParameter('register'));
if ($this->form->isValid()) {
mysfLog::log($this, "DEBUG: " . print_r($this->form->getValues(), TRUE));
$this->form_ref =& $this->form;
$username = $this->form->getValue('email');
$password = $this->form->getValue('password');
$sfGuardUser = new sfGuardUser();
$sfGuardUser->setUsername($username);
$sfGuardUser->setPassword($password);
// Not until confirmed
$sfGuardUser->setIsActive(false);
$profile = $sfGuardUser->getProfile();
$sfGuardUser->save();
// save sfGuardUser before we populate the user profile because we need the user id
$this->myPopulateProfileSettings($profile, $sfGuardUser);
$profile->save();
// Email start
$opts = array();
$opts['from_name'] = sfConfig::get('app_mail_fromname', "Spectralmind");
$opts['from_email'] = sfConfig::get('app_mail_from', "office@spectralmind.com");
$opts['parameters'] = array('validate' => $profile->getValidate());
$opts['body_is_partial'] = true;
$opts['to_name'] = $profile->getName();
$opts['to_email'] = $profile->getEmail();
$opts['subject'] = sfConfig::get('app_mail_subjectconfirmmail', "Confirm your registration");
//$opts['html'] = "sendValidateNew";
$opts['text'] = "sendValidateNew";
/*
// Or to use the Echo Logger
$logger = new Swift_Plugins_Loggers_EchoLogger();
$this->getMailer()->registerPlugin(new Swift_Plugins_LoggerPlugin($logger));
* */
$numSent = smintMailHelper::mail($opts);
// not sent? react accordingly
if ($numSent != 1) {
mysfLog::log($this, "ERROR: confirmation email not sent. Return value was {$numSent}");
return 'Error';
}
mysfLog::log($this, "DEBUG: Confirm link:" . url_for("sfApply/confirm?validate=" . $profile->getValidate(), true));
return 'After';
}
}
}
示例12: getTaskUser
/**
* DOCUMENT ME
* @return mixed
*/
public static function getTaskUser()
{
$user = Doctrine::getTable('sfGuardUser')->findOneByUsername('ataskuser');
if (!$user) {
$user = new sfGuardUser();
$user->setUsername('ataskuser');
// Set a good unique password just in case someone cluelessly sets the active flag.
// This further ensures that no one can ever log in with this account
$user->setPassword(aGuid::generate());
// Prevents normal login
$user->setIsActive(false);
$user->setIsSuperAdmin(true);
$user->save();
}
return $user;
}
示例13: create_sf_user
protected function create_sf_user($fbProfile)
{
try {
//die('creating');
//doctrine, create record in sf_guard_user
$NewFacebookUser = new sfGuardUser();
$NewFacebookUser->first_name = $fbProfile['first_name'];
$NewFacebookUser->last_name = $fbProfile['last_name'];
$NewFacebookUser->email_address = $fbProfile['email'];
$NewFacebookUser->username = $fbProfile['email'];
$NewFacebookUser->save();
$NewFacebookUser->setPassword('test');
$NewFacebookUser->save();
//get id
$id = $NewFacebookUser->getId();
//this part has been replace with a mysql trigger
/*
//ensure id isn't already used, autoincremenet problem
$q = Doctrine_Query::create()
->select("*")
->from("RidAccounts")
//->where("email = ?", $this->user->getEmailAddress())
->where("id = ?", $id)
->setHydrationMode(Doctrine::HYDRATE_ARRAY);
$results = $q->execute();
if(count($results) > 0) { die('id already used' . __LINE__ . __FILE__); }
//doctrine, create record in RidAccounts
$NewFacebookUserAccount = new RidAccounts();
$NewFacebookUserAccount->id = $id;
$NewFacebookUserAccount->first_name = $fbProfile['first_name'];
$NewFacebookUserAccount->last_name = $fbProfile['last_name'];
$NewFacebookUserAccount->email = $fbProfile['email'];
$NewFacebookUserAccount->save();
*/
return $id;
} catch (Exception $e) {
echo $e->getType() . "<br />";
echo $e->getMessage() . "<br />";
sfContext::getInstance()->getLogger()->debug($e->getType());
sfContext::getInstance()->getLogger()->debug($e->getMessage());
die(__FILE__ . __LINE__);
}
}
示例14: executeApply
public function executeApply()
{
if ($this->getRequest()->getMethod() == sfRequest::POST) {
$username = $this->getRequestParameter('username');
$password = $this->getRequestParameter('password');
$sfGuardUser = new sfGuardUser();
$sfGuardUser->setUsername($username);
$sfGuardUser->setPassword($password);
// Not until confirmed
$sfGuardUser->setIsActive(false);
$profile = $sfGuardUser->getProfile();
$this->populateProfileSettings($profile);
$sfGuardUser->save();
$profile->save();
$this->setFlash('sfApplyPlugin_id', $sfGuardUser->getId(), false);
$this->sendEmail('sfApply', 'sendValidate');
return 'After';
}
}
示例15: executeSignUp
public function executeSignUp($request)
{
$this->form = new SignUpForm();
if ($request->isMethod('get')) {
return;
}
$this->form->bind($request->getParameter('form'));
if (!$this->form->isValid()) {
return;
}
$sfGuardUser = new sfGuardUser();
$sfGuardUser->setUsername($this->form->getValue('username'));
$sfGuardUser->setPassword($this->form->getValue('password'));
$sfGuardUser->setIsActive(false);
$sfGuardUser->save();
$sfGuardUserProfile = new sfGuardUserProfile();
$sfGuardUserProfile->setSfGuardUser($sfGuardUser);
$sfGuardUserProfile->setEmail($this->form->getValue('email'));
$sfGuardUserProfile->setFirstName($this->form->getValue('first_name'));
$sfGuardUserProfile->setLastName($this->form->getValue('last_name'));
$sfGuardUserProfile->setGender($this->form->getValue('gender'));
$sfGuardUserProfile->setBirthday($this->form->getValue('birthday'));
$sfGuardUserProfile->setWebpage($this->form->getValue('webpage'));
$sfGuardUserProfile->save();
try {
$connection = new Swift_Connection_SMTP('mail.sis-nav.com', 25);
$connection->setUsername('umut.utkan@sistemas.com.tr');
$connection->setPassword('gahve123');
$mailer = new Swift($connection);
$message = new Swift_Message('Account Confirmation');
$mailContext = array('email' => $sfGuardUserProfile->getEmail(), 'full_name' => $sfGuardUserProfile->getFullName(), 'activation_key' => $sfGuardUserProfile->getActivationKey());
$message->attach(new Swift_Message_Part($this->getPartial('mail/signUpHtmlBody', $mailContext), 'text/html'));
$message->attach(new Swift_Message_Part($this->getPartial('mail/signUpTextBody', $mailContext), 'text/plain'));
$mailer->send($message, $sfGuardUserProfile->getEmail(), 'admin@project-y.com');
$mailer->disconnect();
} catch (Exception $e) {
$mailer->disconnect();
}
$this->getUser()->setFlash('info', 'A confirmation email has been sent to your email address.');
$this->forward('site', 'message');
}