login() public méthode

登录
public login ( $username, $password, boolean $auto_login = false ) : boolean
$username
$password
$auto_login boolean 是否自动登录
Résultat boolean
Exemple #1
0
 /**
  * 登陆页面
  */
 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");
 }