login() 공개 메소드

登录
public login ( $username, $password, boolean $auto_login = false ) : boolean
$username
$password
$auto_login boolean 是否自动登录
리턴 boolean
예제 #1
0
파일: Page.php 프로젝트: xiangdong1987/Slob
 /**
  * 登陆页面
  */
 function login()
 {
     if (isPost()) {
         $username = getRequest('username');
         $password = getRequest('password');
         $authCode = getRequest('authCode');
         if (!$this->verifyPicCaptcha($authCode)) {
             $this->tpl->assign('error', '图片验证码不正确');
         } else {
             $config = Swoole::$php->config['user'];
             $auth = new Swoole\Auth($config);
             $flag = $auth->login($username, $password);
             if ($flag) {
                 $user = $auth->getUid();
                 $_SESSION["role"] = $user["role"];
                 $this->http->redirect(WEBROOT . "/home/index");
             } else {
                 $this->tpl->assign('error', '账户名或者密码错误');
             }
         }
     }
     $this->tpl->display("page/login.html");
 }