示例#1
0
 function setUserForeverCookie()
 {
     $uHash = UserValidationHash::add($this->getUserID(), UVTYPE_LOGIN_FOREVER);
     setcookie("ccmUserHash", $uHash, time() + USER_FOREVER_COOKIE_LIFETIME, DIR_REL . '/', defined('SESSION_COOKIE_PARAM_DOMAIN') ? SESSION_COOKIE_PARAM_DOMAIN : '', defined('SESSION_COOKIE_PARAM_SECURE') ? SESSION_COOKIE_PARAM_SECURE : false, defined('SESSION_COOKIE_PARAM_HTTPONLY') ? SESSION_COOKIE_PARAM_HTTPONLY : false);
 }
示例#2
0
 public function forgot_password()
 {
     $loginData['success'] = 0;
     $vs = Loader::helper('validation/strings');
     $em = $this->post('uEmail');
     try {
         if (!$vs->email($em)) {
             throw new Exception(t('Invalid email address.'));
         }
         $oUser = UserInfo::getByEmail($em);
         if (!$oUser) {
             throw new Exception(t('We have no record of that email address.'));
         }
         $mh = Loader::helper('mail');
         //$mh->addParameter('uPassword', $oUser->resetUserPassword());
         if (USER_REGISTRATION_WITH_EMAIL_ADDRESS) {
             $mh->addParameter('uName', $oUser->getUserEmail());
         } else {
             $mh->addParameter('uName', $oUser->getUserName());
         }
         $mh->to($oUser->getUserEmail());
         //generate hash that'll be used to authenticate user, allowing them to change their password
         $uHash = UserValidationHash::add($oUser->getUserID(), UVTYPE_CHANGE_PASSWORD, true);
         $changePassURL = BASE_URL . View::url('/login', 'change_password', $uHash);
         $mh->addParameter('changePassURL', $changePassURL);
         if (defined('EMAIL_ADDRESS_FORGOT_PASSWORD')) {
             $mh->from(EMAIL_ADDRESS_FORGOT_PASSWORD, t('Forgot Password'));
         } else {
             $adminUser = UserInfo::getByID(USER_SUPER_ID);
             if (is_object($adminUser)) {
                 $mh->from($adminUser->getUserEmail(), t('Forgot Password'));
             }
         }
         $mh->load('forgot_password');
         @$mh->sendMail();
         $loginData['success'] = 1;
         $loginData['msg'] = $this->getPasswordSentMsg();
     } catch (Exception $e) {
         $this->error->add($e);
         $loginData['error'] = $e->getMessage();
     }
     if ($_REQUEST['format'] == 'JSON') {
         $jsonHelper = Loader::helper('json');
         echo $jsonHelper->encode($loginData);
         die;
     }
     if ($loginData['success'] == 1) {
         $this->redirect('/login', 'password_sent');
     }
 }