コード例 #1
0
 public function loadResetPassword($parameters)
 {
     if (!isset($parameters['k'])) {
         return $this->loadModule('admin', 'home', 'default', true, true);
     }
     $user = new DinklyUser($this->db);
     $user->initWith(array('auto_login_hash' => $parameters['k']));
     if (!$user->getId()) {
         return $this->loadModule('admin', 'login', 'forgot_password', true);
     }
     if (!strtotime($user->getAutoLoginExpire()) > time()) {
         DinklyFlash::set('reset_error', 'Sorry, the link has expired.');
         return $this->loadModule('admin', 'login', 'forgot_password', true);
     }
     if (isset($_POST['password']) && isset($_POST['password-confirm'])) {
         if ($_POST['password'] != $_POST['password-confirm']) {
             DinklyFlash::set('reset_error', 'Passwords did not match');
         } elseif (strlen($_POST['password']) < 8) {
             DinklyFlash::set('reset_error', 'Password must be at least 8 characters long');
         } else {
             $user->setPassword($_POST['password']);
             $user->setAutoLoginHash('');
             $user->setAutoLoginExpire('');
             $user->save();
             DinklyFlash::set('reset_success', ' Your password was successfully set. Please login using your new password.');
             return $this->loadModule('admin', 'login', 'default', true);
         }
     }
     return true;
 }