From: <gem...@li...> - 2011-11-03 13:37:27
|
Revision: 173 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=173&view=rev Author: michieltcs Date: 2011-11-03 13:37:18 +0000 (Thu, 03 Nov 2011) Log Message: ----------- Move getRandomPassword() to escort, make it public Modified Paths: -------------- trunk/library/classes/Gems/Default/IndexAction.php trunk/library/classes/GemsEscort.php Modified: trunk/library/classes/Gems/Default/IndexAction.php =================================================================== --- trunk/library/classes/Gems/Default/IndexAction.php 2011-11-03 13:23:03 UTC (rev 172) +++ trunk/library/classes/Gems/Default/IndexAction.php 2011-11-03 13:37:18 UTC (rev 173) @@ -273,26 +273,6 @@ $this->_reroute(array('action' => 'index'), true); } - protected function _getRandomPassword() - { - $salt = "abcdefghjkmnpqrstuvwxyzABCDEFGHJKMNPQRSTUVWXYZ0123456789"; - $pass = ""; - - srand((double)microtime()*1000000); - - $i = 0; - - while ($i <= 7) - { - $num = rand() % strlen($salt); - $tmp = substr($salt, $num, 1); - $pass = $pass . $tmp; - $i++; - } - - return $pass; - } - protected function _getResetForm() { $form = new Gems_Form(array('labelWidthFactor' => $this->labelWidthFactor)); @@ -362,7 +342,7 @@ if (!empty($result)) { // generate new password - $password = $this->_getRandomPassword(); + $password = $this->escort->getRandomPassword(); $passwordHash = $this->escort->passwordHash(null, $password, false); $mail->setSubject('New password'); Modified: trunk/library/classes/GemsEscort.php =================================================================== --- trunk/library/classes/GemsEscort.php 2011-11-03 13:23:03 UTC (rev 172) +++ trunk/library/classes/GemsEscort.php 2011-11-03 13:37:18 UTC (rev 173) @@ -1319,7 +1319,31 @@ { return $this->project->getValueHash($value); } + + /** + * Generate random password + * @return string + */ + public function getRandomPassword() + { + $salt = "abcdefghjkmnpqrstuvwxyzABCDEFGHJKMNPQRSTUVWXYZ0123456789"; + $pass = ""; + srand((double)microtime()*1000000); + + $i = 0; + + while ($i <= 7) + { + $num = rand() % strlen($salt); + $tmp = substr($salt, $num, 1); + $pass = $pass . $tmp; + $i++; + } + + return $pass; + } + /** * Hook 12: Called after an action is dispatched by Zend_Controller_Dispatcher. * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |