Esempio n. 1
0
 /**
  * 执行用户登录
  *
  * @return boolean
  */
 public function accountAction()
 {
     $email = $this->getRequest()->getPost('email');
     $password = $this->getRequest()->getPost('password');
     if (empty($email)) {
         Page::displayError('Please enter email');
     }
     if (empty($password)) {
         Page::displayError('Please enter password');
     }
     if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
         Page::displayError('Email format error');
     }
     $userInfo = $this->models['userModel']->getUserByEmail($email);
     if (empty($userInfo)) {
         Page::displayError('User not exist');
     }
     // 检查密码
     if ($userInfo['password'] == md5(md5($password) . $userInfo['salt'])) {
         // 写入 Cookies
         Local\Header\Cookies::setCookie('email', $userInfo['email']);
         Local\Header\Cookies::setCookie('password', $userInfo['password']);
         // 更新最后登录时间
         $this->models['userModel']->updateLastLoginTime($userInfo['userid']);
         $this->redirect('/index');
     } else {
         Page::displayError('Email or password is not correct');
     }
     return FALSE;
 }
Esempio n. 2
0
 /**
  * 执行新用户注册
  *
  */
 public function accountAction()
 {
     $email = $this->getRequest()->getPost('email');
     $password = $this->getRequest()->getPost('password');
     $repassword = $this->getRequest()->getPost('repassword');
     if (empty($email)) {
         Page::displayError('Please enter email');
     }
     if (empty($password)) {
         Page::displayError('Please enter password');
     }
     if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
         Page::displayError('Email format error');
     }
     if (strlen($password) < USER_PASSWORD_MIN || strlen($password) > USER_PASSWORD_MAX) {
         Page::displayError('Password length is not correct');
     }
     if ($password != $repassword) {
         Page::displayError('The two passwords do not match');
     }
     // 查询邮箱是否已经注册
     if ($this->models['userModel']->getUserByEmail($email)) {
         Page::displayError('Email registered');
     }
     // 写入数据
     $this->models['userModel']->newUser($email, $password);
     Page::displayMessage('Register successful', '/login');
 }
Esempio n. 3
0
 /**
  * 执行提交GIT数据
  *
  */
 public function doAction()
 {
     $data['title'] = $this->getRequest()->getPost('title');
     $data['categoryid'] = (int) $this->getRequest()->getPost('categoryid');
     $data['url'] = $this->getRequest()->getPost('url');
     $data['memo'] = $this->getRequest()->getPost('memo');
     $data['userid'] = Yaf\Registry::get('userInfo')['userid'];
     $data['dateline'] = TIMENOW;
     if (empty($data['title'])) {
         Page::displayError('Project name cannot be empty');
     }
     if (empty($data['categoryid'])) {
         Page::displayError('Please select a category');
     }
     if (empty($data['url'])) {
         Page::displayError('Project URL cannot be empty');
     }
     if (empty($data['memo'])) {
         Page::displayError('Project description cannot be empty');
     }
     $this->models['gitModel']->saveData($data);
     unset($data);
     Page::displayMessage('Successful submission Please wait for audit', '/add');
     return FALSE;
 }