Changeset 254
- Timestamp:
- 04/10/08 00:02:40 (9 months ago)
- Files:
-
- trunk/Framework/Module/Login.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Framework/Module/Login.php
r238 r254 6 6 * Framework_Module_Login 7 7 * 8 * @author Bill Shupp <hostmaster@shupp.org> 9 * @copyright Bill Shupp <hostmaster@shupp.org> 10 * @package ToasterAdmin 11 * @subpackage Module 12 * @filesource 8 * PHP Version 5.1.0+ 9 * 10 * @category Mail 11 * @package ToasterAdmin 12 * @subpackage Module 13 * @author Bill Shupp <hostmaster@shupp.org> 14 * @copyright 2007-2008 Bill Shupp <hostmaster@shupp.org> 15 * @license GPL 2.0 {@link http://www.gnu.org/licenses/gpl.txt} 16 * @link http://trac.merchbox.com/trac/toasteradmin 13 17 */ 14 18 … … 16 20 * Framework_Module_Login 17 21 * 18 * @author Bill Shupp <hostmaster@shupp.org> 19 * @package ToasterAdmin 20 * @subpackage Module 22 * @category Mail 23 * @package ToasterAdmin 24 * @subpackage Module 25 * @author Bill Shupp <hostmaster@shupp.org> 26 * @copyright 2007-2008 Bill Shupp <hostmaster@shupp.org> 27 * @license GPL 2.0 {@link http://www.gnu.org/licenses/gpl.txt} 28 * @link http://trac.merchbox.com/trac/toasteradmin 21 29 */ 22 30 class Framework_Module_Login extends Framework_Auth_No … … 25 33 * __default 26 34 * 27 * @access public 28 * @return mixed 35 * Just display the login form. 36 * 37 * @access public 38 * @return void 29 39 */ 30 40 public function __default() … … 35 45 } 36 46 47 /** 48 * loginNow 49 * 50 * Try and log the user in. 51 * 52 * @access public 53 * @return void 54 */ 37 55 public function loginNow() 38 56 { 39 57 $this->tplFile = 'Login.tpl'; 58 40 59 $form = $this->createLoginForm(); 41 60 if ($form->validate()) { 42 if (!$result = $this->user->authenticate($_POST['email'], $_POST['password'])) { 61 $result = $this->user->authenticate($_POST['email'], $_POST['password']); 62 if (!$result) { 43 63 $this->setData('loginError', _('Login failed')); 44 64 $this->setData('QF_Form', $form->toHtml()); 45 $this->session->email = null;65 $this->session->email = null; 46 66 $this->session->password = null; 47 67 return; 48 68 } 69 49 70 $crypt = new Crypt_Blowfish((string)Framework::$site->config->mcryptKey); 50 $emailArray = explode('@', $_POST['email']); 51 $this->session->user = $emailArray[0]; 52 $this->session->domain = $emailArray[1]; 53 $this->session->email = $_POST['email']; 54 $this->session->password = $crypt->encrypt($_POST['password']); 71 72 $emailArray = explode('@', $_POST['email']); 73 $this->session->user = $emailArray[0]; 74 $this->session->domain = $emailArray[1]; 75 $this->session->email = $_POST['email']; 76 $this->session->password = $crypt->encrypt($_POST['password']); 55 77 $this->session->lastActionTime = time(); 56 78 header('Location: ./index.php?module=Home'); … … 61 83 } 62 84 63 private function createLoginForm() 85 /** 86 * createLoginForm 87 * 88 * Create HTML_QuickForm object for the login form 89 * 90 * @access protected 91 * @return object HTML_QuickForm object 92 */ 93 protected function createLoginForm() 64 94 { 65 $form = new HTML_QuickForm('formLogin', 'post', $_SERVER['REQUEST_URI'] . '&event=loginNow'); 95 $form = new HTML_QuickForm('formLogin', 'post', 96 $_SERVER['REQUEST_URI'] . '&event=loginNow'); 66 97 67 98 $form->addElement('header', 'MyHeader', _('Login')); … … 70 101 $form->addElement('submit', 'submit', _('Login')); 71 102 72 $form->addRule('email', _('Please enter your email address'), 'required', null, 'client'); 73 $form->addRule('email', _('Please enter a valid email address'), 'email', null, 'client'); 74 $form->addRule('password', _('Please enter your password'), 'required', null, 'client'); 103 $form->addRule('email', _('Please enter your email address'), 104 'required', null, 'client'); 105 $form->addRule('email', _('Please enter a valid email address'), 106 'email', null, 'client'); 107 $form->addRule('password', _('Please enter your password'), 108 'required', null, 'client'); 75 109 $form->applyFilter('__ALL__', 'trim'); 76 110 … … 78 112 } 79 113 80 function logoutNow() { 114 /** 115 * logoutNow 116 * 117 * Log the user out. 118 * 119 * @access public 120 * @return void 121 */ 122 public function logoutNow() 123 { 81 124 $this->session->destroy(); 82 125 $this->setData('message', _('Logged out successfully')); … … 84 127 } 85 128 86 function logoutInactive() { 129 /** 130 * logoutInactive 131 * 132 * Log the user out for inactivity 133 * 134 * @access public 135 * @return void 136 */ 137 public function logoutInactive() 138 { 87 139 $this->session->destroy(); 88 $this->setData('message', _('You have been logged out automatically for inactivity')); 140 $this->setData('message', 141 _('You have been logged out automatically for inactivity')); 89 142 return $this->__default(); 90 143 } 91 92 144 } 93 145
