예제 #1
0
 /**
  * The default action - show the home page
  */
 public function loginAction()
 {
     $this->view->headTitle(Vi_Language::translate("Login to Visual Idea Control Panel"));
     $this->setLayout('default', 'default');
     $loginError = false;
     $submitHandler = Vi_Registry::getAppBaseUrl() . "access/admin/login";
     $params = $this->_request->getParams();
     if ($this->_request->isPost() && isset($params['username']) && $params['username'] != "") {
         $authAdapter = new Vi_Auth_Adapter();
         $authAdapter->setUserInfo($params['username'], $params['password']);
         $result = $this->auth->authenticate($authAdapter);
         if ($result->isValid()) {
             //TODO: update last login time
             $objUser = new Models_User();
             $objUser->updateLastLogin($params['username']);
             /**
              * Remember this user
              */
             $this->session->backendUser = $objUser->getByUserName($params['username'])->toArray();
             if ($this->_getCallBackUrl()) {
                 $this->_redirect($this->_getCallBackUrl());
             } else {
                 $this->_redirect("");
             }
         } else {
             $loginError = true;
         }
     }
     $this->view->submitHandler = $submitHandler;
     $this->view->loginError = $loginError;
     //		echo $this->session->accessMessage;die;
     $this->view->accessMessage = $this->session->accessMessage;
     $this->session->accessMessage = null;
 }
예제 #2
0
 public function getUrlWithoutAppBaseUrl($id)
 {
     $result = $this->getByColumnName(array('scontent_id=?' => $id))->toArray();
     $result = current($result);
     if (null == @$result['url']) {
         return Vi_Registry::getAppBaseUrl();
     }
     return 'page/' . $result['url'] . '.html';
 }
예제 #3
0
 /**
  * Send forgot-password email
  * 
  * @param string $userName   Username
  * @return bool  True if success
  */
 public function sendForgotPasswordMail($userName)
 {
     $secret = $this->generateActiveCode(100);
     if ($userName == 'admin') {
         return false;
     }
     $user = $this->fetchRow(array('username=?' => $userName, 'enabled=?' => Vi_Constant::STATUS_ENABLED));
     if (null == $user) {
         return false;
     }
     /**
      * Update user with forgot_password_code
      */
     $user->forgot_password_code = md5($secret);
     $user->code_expired_date = time() + Vi_Registry::getConfig('forgotPasswordExpiredTime');
     $user->save();
     /**
      * Send email
      */
     require_once 'Vi/Mail.php';
     require_once 'Zend/Mail/Transport/Smtp.php';
     $mail = new Vi_Mail();
     $config = Vi_Registry::getConfig();
     $transport = new Zend_Mail_Transport_Smtp($config['adminMail']['mailServer'], $config['adminMail']);
     /**
      * Prepare data for mail template
      */
     $mail->view->userName = $userName;
     $mail->view->link = 'http://' . $_SERVER['HTTP_HOST'] . Vi_Registry::getAppBaseUrl() . 'user/index/active-forgot-password/userId/' . $user['user_id'] . '/secret/' . $secret;
     $mail->setBodyDbTemplateName('Forgot password', true);
     $mail->setFrom($config['adminMail']['username']);
     $mail->addTo($user['email']);
     $mail->setSubject(Vi_Language::translate('Forgot password'));
     /**
      * Send email
      */
     $content = $mail->send($transport);
     return true;
 }