From dc8e3da6db030440b7d080e220d460058443db22 Mon Sep 17 00:00:00 2001 From: denise Date: Fri, 24 Aug 2012 12:40:30 -0400 Subject: [PATCH] CC-4283: Password Reset: Please let user input username they want to reset -done --- .../application/controllers/LoginController.php | 13 ++++++++++--- airtime_mvc/application/forms/PasswordRestore.php | 11 +++++++++++ airtime_mvc/application/models/Auth.php | 3 ++- .../views/scripts/form/password-restore.phtml | 14 +++++++++++--- 4 files changed, 34 insertions(+), 7 deletions(-) diff --git a/airtime_mvc/application/controllers/LoginController.php b/airtime_mvc/application/controllers/LoginController.php index ca0076e52..a47a5c420 100644 --- a/airtime_mvc/application/controllers/LoginController.php +++ b/airtime_mvc/application/controllers/LoginController.php @@ -110,9 +110,16 @@ class LoginController extends Zend_Controller_Action $request = $this->getRequest(); if ($request->isPost() && $form->isValid($request->getPost())) { - $user = CcSubjsQuery::create() - ->filterByDbEmail($form->email->getValue()) - ->findOne(); + if (is_null($form->username->getValue()) || $form->username->getValue() == '') { + $user = CcSubjsQuery::create() + ->filterByDbEmail($form->email->getValue()) + ->findOne(); + } else { + $user = CcSubjsQuery::create() + ->filterByDbEmail($form->email->getValue()) + ->filterByDbLogin($form->username->getValue()) + ->findOne(); + } if (!empty($user)) { $auth = new Application_Model_Auth(); diff --git a/airtime_mvc/application/forms/PasswordRestore.php b/airtime_mvc/application/forms/PasswordRestore.php index 80e3ac1f1..eaa42ba1f 100644 --- a/airtime_mvc/application/forms/PasswordRestore.php +++ b/airtime_mvc/application/forms/PasswordRestore.php @@ -20,6 +20,17 @@ class Application_Form_PasswordRestore extends Zend_Form 'ViewHelper' ) )); + + $this->addElement('text', 'username', array( + 'label' => 'Username', + 'required' => false, + 'filters' => array( + 'stringTrim', + ), + 'decorators' => array( + 'ViewHelper' + ) + )); $this->addElement('submit', 'submit', array( 'label' => 'Restore password', diff --git a/airtime_mvc/application/models/Auth.php b/airtime_mvc/application/models/Auth.php index c287a0335..2aef1ce81 100644 --- a/airtime_mvc/application/models/Auth.php +++ b/airtime_mvc/application/models/Auth.php @@ -30,7 +30,8 @@ class Application_Model_Auth $e_link_port = $_SERVER['SERVER_PORT']; $e_link_path = $view->url(array('user_id' => $user->getDbId(), 'token' => $token), 'password-change'); - $message = "Click this link: {$e_link_protocol}://{$e_link_base}:{$e_link_port}{$e_link_path}"; + $message = "Hi {$user->getDbLogin()}, \n\nClick this link to reset your password: "; + $message .= "{$e_link_protocol}://{$e_link_base}:{$e_link_port}{$e_link_path}"; $success = Application_Model_Email::send('Airtime Password Reset', $message, $user->getDbEmail()); diff --git a/airtime_mvc/application/views/scripts/form/password-restore.phtml b/airtime_mvc/application/views/scripts/form/password-restore.phtml index a617ec971..a43b9fe36 100644 --- a/airtime_mvc/application/views/scripts/form/password-restore.phtml +++ b/airtime_mvc/application/views/scripts/form/password-restore.phtml @@ -1,11 +1,20 @@
-
+
+ element->getElement('username') ?> +
+ +
+ +
+
element->getElement('email') ?>
element->getElement('email')->hasErrors()): ?> @@ -15,7 +24,6 @@ -