本文整理汇总了PHP中sfGuardUser::setIsActive方法的典型用法代码示例。如果您正苦于以下问题:PHP sfGuardUser::setIsActive方法的具体用法?PHP sfGuardUser::setIsActive怎么用?PHP sfGuardUser::setIsActive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfGuardUser
的用法示例。
在下文中一共展示了sfGuardUser::setIsActive方法的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: 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', 'noreply@example.org');
$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');
}
}
}
示例3: 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;
}
示例4: 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->setIsActive(true);
$user->save();
$this->logSection('guard', sprintf('Create user "%s"', $arguments['username']));
}
示例5: 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);
}
示例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: 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: 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';
}
}
}
示例10: 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;
}
示例11: executeRegister
/**
* Executes register action
*
* @param sfWebRequest $request A request object
*/
public function executeRegister(sfWebRequest $request)
{
if (!StoreTable::getInstance()->getValueCached(StoreTable::REGISTER_ON)) {
return $this->notFound();
}
$user = new sfGuardUser();
$this->form = new RegisterForm($user);
if ($request->getGetParameter('widgetval')) {
$storage = sfContext::getInstance()->getStorage();
if ($storage instanceof policatSessionStorage) {
$storage->needSession();
}
$this->getUser()->setAttribute(myUser::SESSION_WIDGETVAL_ON, 1);
}
if ($request->isMethod('post')) {
if (!$this->getUser()->human()) {
return $this->captchaModal();
}
$this->form->bind($request->getPostParameter($this->form->getName()));
if ($this->form->isValid()) {
$user->setIsActive(false);
$user = $this->form->updateObject();
$user->setUsername($user->getEmailAddress());
$user->setValidationKind(sfGuardUserTable::VALIDATION_KIND_REGISTER_LINK);
$user->randomValidationCode();
$user->save();
$user->addPermissionByName(myUser::CREDENTIAL_USER);
$subject = 'validate register';
$body = "#VALIDATION-URL#";
$store = StoreTable::getInstance()->findByKeyAndLanguageWithFallback(StoreTable::REGISTER_MAIL, $user->getLanguageId());
if ($store) {
$subject = $store->getField('subject');
$body = $store->getField('body');
}
$subst = array('#VALIDATION-URL#' => $this->generateUrl('register_validation', array('id' => $user->getId(), 'code' => $user->getValidationCode()), true), '#USER-NAME#' => $user->getFullName());
UtilMail::send(null, null, $user->getEmailAddress(), $subject, $body, null, $subst);
return $this->ajax()->form($this->form)->attr('#register_form input, #register_form select, #register_form button', 'disabled', 'disabled')->scroll()->alert('Congratulations! You have created a new account. For your first login, you need to check your inbox ' . 'and click the account validation link in the e-mail we have sent to you.', 'Please check your inbox now!', '.page-header', 'after')->render();
} else {
return $this->ajax()->form($this->form)->render();
}
}
$this->includeChosen();
}
示例12: 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';
}
}
示例13: 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');
}
示例14: executeIdentification
public function executeIdentification(sfWebRequest $request)
{
if (!$this->getUser()->isAuthenticated()) {
$this->formInscription = new InscriptionForm();
$class = sfConfig::get('app_sf_guard_plugin_signin_form', 'sfGuardFormSignin');
$this->form = new $class();
if ($request->ismethod('post')) {
if ($request->getParameter('send') == "signin") {
$this->form->bind($request->getParameter('signin'));
if ($this->form->isValid()) {
$values = $this->form->getValues();
$this->getUser()->signin($values['user'], array_key_exists('remember', $values) ? $values['remember'] : false);
if ($this->getUser()->getAttribute('montantLocation')) {
$paypal = new PayPal();
$ret = $paypal->doExpressCheckout($this->getUser()->getAttribute('montantLocation'), 'Location de la voiture');
print_r($ret);
} else {
$this->redirect('espace_membre_profil');
}
}
} else {
if ($request->getParameter('send') == "signup") {
$this->formInscription->bind($request->getParameter('signup'));
if ($this->formInscription->isValid()) {
$values = $this->formInscription->getValues();
//print_r($values);
//exit;
$user = new sfGuardUser();
$user->setEmailAddress($values['email_address']);
$user->setUsername($values['email_address']);
$user->setLastName($values['nom']);
$user->setFirstName($values['prenom']);
$user->setPassword($values['password1']);
$user->setIsActive(1);
$user->getProfile()->setAdresse($values['adresse']);
$user->getProfile()->setCodepostal($values['codepostal']);
$user->getProfile()->setVille($values['ville']);
$user->getProfile()->setFixe($values['fixe']);
$user->getProfile()->setMobile($values['mobile']);
$user->getProfile()->setDateNaissance($values['date_naissance']);
$user->getProfile()->setNumeroPermis($values['numero_permis']);
$user->getProfile()->setVilleDelivrance($values['ville_permis']);
$user->getProfile()->setPaysDelivrance($values['pays_permis']);
$user->getProfile()->setDateDelivrance($values['date_delivrance_permis']);
$user->getProfile()->setIsActivated(1);
$user->addGroupByName("client");
$user->save();
$this->getUser()->setAttribute('email_address', $values['email_address']);
$message = $this->getMailer()->compose(sfConfig::get('app_mail_saidi'), $values['email_address'], '[Mobilyrent] - Inscription Mobilyrent location de voiture', '[Mobilyrent] - Inscription Mobilyrent location de voiture');
$this->getMailer()->send($message);
//echo $this->getUser()->getAttribute('montantLocation');exit;
if ($this->getUser()->getAttribute('montantLocation')) {
$paypal = new PayPal();
$ret = $paypal->doExpressCheckout($this->getUser()->getAttribute('montantLocation'), 'Location de la voiture');
print_r($ret);
}
//$this->getUser()->setFlash('notice', sprintf('Inscription terminée.<br/>Un email vous a été envoyé. Connectez vous et continuer votre reservation.'));
}
}
}
}
} else {
$paypal = new PayPal();
$ret = $paypal->doExpressCheckout($this->getUser()->getAttribute('montantLocation'), 'Location de la voiture');
print_r($ret);
}
}
示例15: 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');
}
}