Changeset 54
- Timestamp:
- 05/25/08 22:40:52 (2 years ago)
- Files:
-
- trunk/apps/main/lib/myActions.class.php (modified) (1 diff)
- trunk/apps/main/modules/sfGuardAuth/actions/actions.class.php (modified) (3 diffs)
- trunk/apps/main/modules/sfGuardAuth/templates/registerSuccess.php (modified) (1 diff)
- trunk/apps/main/modules/sfGuardAuth/templates/resendActivationSuccess.php (modified) (1 diff)
- trunk/apps/main/modules/sfGuardAuth/templates/signinSuccess.php (modified) (1 diff)
- trunk/apps/main/templates/_messages.php (modified) (3 diffs)
- trunk/config/ProjectConfiguration.class.php (modified) (1 diff)
- trunk/lib/form/user/ResendActivationForm.class.php (added)
- trunk/lib/form/user/SigninForm.class.php (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/apps/main/lib/myActions.class.php
r48 r54 382 382 } 383 383 } 384 385 /** 386 * Post execution: if a form has been set, we put it in sfContext to be able 387 * to reference it in the layout or partials 388 * 389 */ 390 public function postExecute() 391 { 392 if (isset($this->form) && $this->form instanceof sfForm) 393 { 394 $this->getContext()->set('form', $this->form); 395 } 396 } 384 397 385 398 } trunk/apps/main/modules/sfGuardAuth/actions/actions.class.php
r53 r54 280 280 public function executeResendActivation(sfWebRequest $request) 281 281 { 282 $this->form = new ResendActivationForm(); 283 282 284 if ($request->isMethod('post')) 283 285 { 284 $email = $request->getParameter('email'); 285 $user = sfGuardUserPeer::retrieveByEmail($email); 286 // Recaptcha parameters 287 $captcha = array( 288 'recaptcha_challenge_field' => $request->getParameter('recaptcha_challenge_field'), 289 'recaptcha_response_field' => $request->getParameter('recaptcha_response_field'), 290 ); 291 $params = array_merge($request->getParameter('user', array()), array('captcha' => $captcha)); 286 292 287 $c = new Criteria; 288 $c->add(ActivationPeer::USER_ID, $user->getId()); 289 $activation = ActivationPeer::doSelectOne($c); 290 $request->setAttribute('activation', $activation); 293 $this->form->bind($params); 291 294 292 $mailSent = $this->sendSwiftSmtpPlainMail('mail', 'resendActivation', 293 $user->getEmail(), 294 $this->__('Please activate your account')); 295 if (!$mailSent) 296 { 297 $request->setError('errors', $this->__('We were unable to send you an email. We are digging the problem, stay tuned.')); 298 return sfView::SUCCESS; 299 } 300 $this->getUser()->setFlash('notice', $this->__('Your activation mail has been sent to '.$user->getEmail())); 301 $this->redirect('@homepage'); 295 if ($this->form->isValid()) 296 { 297 $user = sfGuardUserPeer::retrieveByEmail($params['email']); 298 $this->forward404Unless($user); // theoricaly, can't happen 299 300 $c = new Criteria(); 301 $c->add(ActivationPeer::USER_ID, $user->getId()); 302 $activation = ActivationPeer::doSelectOne($c); 303 $request->setAttribute('activation', $activation); 304 305 $mailSent = $this->sendSwiftSmtpPlainMail('mail', 'resendActivation', 306 $user->getEmail(), 307 $this->__('Please activate your account')); 308 if (!$mailSent) 309 { 310 $this->getUser()->setFlash('warning', $this->__('We were unable to send you an email. We are digging the problem, stay tuned.')); 311 return sfView::SUCCESS; 312 } 313 $this->getUser()->setFlash('notice', $this->__('Your activation mail has been sent to '.$user->getEmail())); 314 $this->redirect('@homepage'); 315 } 302 316 } 303 317 } … … 309 323 310 324 public function handleErrorRegister() 311 {312 return sfView::SUCCESS;313 }314 315 public function handleErrorResendActivation()316 325 { 317 326 return sfView::SUCCESS; … … 381 390 } 382 391 383 public function validateResendActivation()384 {385 if ($this->getRequest()->isMethod('post'))386 {387 $user = sfGuardUserPeer::retrieveByEmail(trim($this->getRequestParameter('email')));388 if (!$user)389 {390 $this->getRequest()->setError('errors', $this->__('This email has never been registered here'));391 return false;392 }393 394 if ($user->getIsActive())395 {396 $this->getRequest()->setError('errors', $this->__('This account is already activated. You do not need an activation mail to log in.'));397 return false;398 }399 400 $c = new Criteria;401 $c->add(ActivationPeer::USER_ID, $user->getId());402 $activation = ActivationPeer::doSelectOne($c);403 if (!$activation)404 {405 $this->getRequest()->setError('errors', $this->__('We cannot find your activation informations. This is badly weird.'));406 $this->logMessage(sprintf('Account "%s" is weird. Check it.', $user->getUsername()));407 return false;408 }409 }410 return true;411 }412 413 392 } trunk/apps/main/modules/sfGuardAuth/templates/registerSuccess.php
r53 r54 31 31 <fieldset> 32 32 <legend><?php echo __('Account informations') ?></legend> 33 <?php echo $form->renderGlobalErrors() ?>34 33 <?php echo $form['username']->renderRow() ?> 35 34 <?php echo $form['email']->renderRow() ?> trunk/apps/main/modules/sfGuardAuth/templates/resendActivationSuccess.php
r53 r54 22 22 <fieldset> 23 23 <legend><?php echo __('Account informations') ?></legend> 24 <?php echo $form->renderGlobalErrors() ?>25 24 <?php echo $form['email']->renderRow() ?> 26 <?php /* 27 <div class="form-row required"> 28 <label for="email"><?php echo __('Email address you provided at registration time') ?></label> 29 <?php echo input_tag('email', $sf_params->get('email')) ?> 30 <?php echo form_error('email') ?> 31 </div> 32 <div class="form-row required"> 33 <?php echo label_for('captcha', __('Security code')) ?> 34 <?php echo input_tag('captcha', null, 'id=captcha style=width:100px'); ?> 35 <?php echo cryptographp_picture() ?> 36 <?php echo cryptographp_reload() ?> 37 <?php echo form_error('captcha') ?> 38 <p class="form-help"> 39 <?php echo __('This codes aims at detecting if you are a bot or a human person.') ?> 40 </p> 41 </div> 42 */ ?> 25 <span class="form-help"><?php echo __('Enter the email address you entered when you have registered here.') ?></span> 26 <?php echo $form['captcha']->renderRow() ?> 27 <p class="form-help"> 28 <?php echo __('This codes aims at detecting if you are a bot or a human person.') ?> 29 </p> 43 30 <p> 44 31 <?php echo $form['_csrf_token'] ?> trunk/apps/main/modules/sfGuardAuth/templates/signinSuccess.php
r53 r54 15 15 <fieldset> 16 16 <legend><?php echo __('Please sign in') ?></legend> 17 <?php echo $form->renderGlobalErrors() ?>18 17 <?php echo $form['username']->renderRow() ?> 19 18 <?php echo $form['password']->renderRow() ?> trunk/apps/main/templates/_messages.php
r48 r54 1 <?php /* 2 <?php if ($sf_request->hasErrors()): ?> 1 <?php if ($sf_context->has('form') && $form = $sf_context->get('form') && $sf_context->get('form')->hasGlobalErrors()): ?> 3 2 <div class="form-errors"> 4 3 <h4><?php echo __('Errors have been encountered') ?></h4> 5 <ul> 6 <?php foreach ($sf_request->getErrorNames() as $name): ?> 7 <li><?php echo $sf_request->getError($name) ?></li> 8 <?php endforeach; ?> 9 </ul> 4 <?php echo $sf_context->get('form')->renderGlobalErrors() ?> 10 5 </div> 11 6 <?php endif; ?> 7 12 8 <?php if ($sf_user->hasFlash('notice')): ?> 13 9 <p class="notice"> … … 15 11 </p> 16 12 <?php endif; ?> 13 17 14 <?php if ($sf_user->hasFlash('warning')): ?> 18 15 <p class="warning"> … … 20 17 </p> 21 18 <?php endif; ?> 22 */ ?> 19 trunk/config/ProjectConfiguration.class.php
r48 r54 7 7 public function setup() 8 8 { 9 sfWidgetFormSchema::setDefaultFormFormatterName('div'); 10 9 11 // symfonians constants definition 10 12 if (!defined('SYMFONIANS_MAIN_DOMAIN'))
