예제 #1
0
 public function avatarAction($uid = null)
 {
     if ($uid) {
         $user = User::findUserByID($uid);
         if ($user) {
             $this->response->redirect($user->getUserprofile()->avatar);
         }
     }
 }
예제 #2
0
 public function loginAction()
 {
     if ($this->_processCookie()) {
         return $this->forward("index/index");
     }
     if ($this->isLoggedin()) {
         $this->flash->error($this->i18n->user_alreadyloggedin);
         return $this->forward("index/index");
     }
     $form = new LoginForm();
     if ($this->request->isPost()) {
         if ($this->security->checkToken()) {
             if (!$form->isValid($this->request->getPost())) {
                 foreach ($form->getMessages() as $message) {
                     $this->flash->error($message);
                 }
             } else {
                 $username = $this->request->getPost('username');
                 $password = $this->request->getPost('password');
                 $user = User::findUserByName($username);
                 if ($user) {
                     if ($this->security->checkHash($password, $user->password)) {
                         $this->_registerSession($user);
                         $ser_authData = serialize($this->session->get("auth"));
                         if ($this->request->getPost('remember-me')) {
                             $this->cookies->set('remember-me', $ser_authData, time() + 7 * 86400, "/", $this->config->application->secure);
                         }
                         $this->flash->success(sprintf($this->i18n->user_login_success, $user->username));
                         return $this->forward('index/index');
                     }
                 }
             }
             $this->flash->error($this->i18n->user_login_wrongdata);
         } else {
             $this->flash->error($this->i18n->security_csrf_error);
         }
     }
     $this->view->setVar("form", $form);
 }
예제 #3
0
파일: User.php 프로젝트: CloudOJ/ums
 public static function findUserByID($uid)
 {
     $user = User::findFirst(array("uid = :uid:", 'bind' => array('uid' => $uid)));
     return $user;
 }