저자: Han Tianfeng
예제 #1
0
 function __construct($swoole)
 {
     parent::__construct($swoole);
     if (isset($_POST["PHPSESSID"])) {
         $_COOKIE['PHPSESSID'] = $_POST["PHPSESSID"];
         session_id($_COOKIE['PHPSESSID']);
     }
     Swoole::$php->session->start();
     Swoole\Auth::$login_url = '/page/login/?';
     if (Swoole\Auth::login_require() === false) {
         return $this->swoole->http->finish();
     }
     $this->uid = $_SESSION['user_id'];
 }
예제 #2
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");
 }
예제 #3
0
 /**
  * 加入认证
  * @param Swoole $swoole
  */
 function __construct(Swoole $swoole)
 {
     parent::__construct($swoole);
     Swoole::$php->session->start();
     Swoole\Auth::login_require();
 }
예제 #4
0
 function home()
 {
     $this->session->start();
     Swoole\Auth::loginRequire();
     $this->display('user/home.php');
 }
예제 #5
0
파일: User.php 프로젝트: ruziyi/framework
 function home()
 {
     $this->session->start();
     var_dump($_SESSION);
     Swoole\Auth::login_require();
 }
예제 #6
0
 function passwd()
 {
     if ($_POST) {
         if (empty($_POST['repass']) or empty($_POST['oldpass']) or empty($_POST['newpass'])) {
             return Swoole\JS::js_back('参数不能为空!');
         }
         if ($_POST['repass'] != $_POST['newpass']) {
             return Swoole\JS::js_back('两次输入的密码不一致!');
         }
         if (strlen($_POST['repass']) < 6) {
             return Swoole\JS::js_back('密码长度不得少于6位!');
         }
         $u = model('UserInfo')->get($this->uid);
         if ($u['password'] != Swoole\Auth::mkpasswd($u['username'], $_POST['oldpass'])) {
             return Swoole\JS::js_back('旧密码错误!');
         }
         $u->password = Swoole\Auth::mkpasswd($u['username'], $_POST['newpass']);
         $u->save();
         return Swoole\JS::js_back('修改成功!');
     } else {
         $this->swoole->tpl->display();
     }
 }
예제 #7
0
파일: User.php 프로젝트: xiangdong1987/Slob
 function home()
 {
     $this->session->start();
     Swoole\Auth::login_require();
 }
예제 #8
0
 function chatroom()
 {
     session();
     Swoole\Auth::$login_url = '/page/login/?';
     Swoole\Auth::login_require();
     $userInfo = createModel('UserInfo');
     $this->swoole->tpl->assign('user', $userInfo->get($_SESSION['user_id'])->get());
     $this->swoole->tpl->display();
 }
예제 #9
0
 function reset_passwd()
 {
     //不是超级用户不能查看修改用户
     if ($this->userinfo['usertype'] != 0) {
         return "access deny";
     }
     if (empty($_GET['id'])) {
         return \Swoole\JS::js_back("操作不合法");
     }
     $uid = intval($_GET['id']);
     $user = table('user')->get($uid);
     if (!$user->exist()) {
         return \Swoole\JS::js_back("用户不存在");
     }
     $user->password = Swoole\Auth::mkpasswd($user->username, '123456');
     if ($user->save()) {
         return \Swoole\JS::js_back("重置密码成功");
     } else {
         return \Swoole\JS::js_back("重置密码失败,请稍后重试");
     }
 }