Exemple #1
0
 /**
  * 判断用户是否登录
  * @return User
  */
 public function isLogin()
 {
     $loginInfo = session(C('LOGIN_INFO'));
     if ($loginInfo) {
         $user = new User();
         $user->setUser($loginInfo);
         $this->userInfo = $user;
     }
     return $this->userInfo;
 }
Exemple #2
0
 /**
  * 用户登录
  * @param $username
  * @param $password
  */
 public function login($username = '', $password = '')
 {
     layout(false);
     //判断否非已经登陆
     if (session(C('LOGIN_INFO'))) {
         $this->redirect('Admin/Index/index');
     }
     //登录判断
     if ($_POST) {
         $user = new User();
         $userInfo = $user->login($username);
         if ($userInfo['password'] === md5($password)) {
             // 登录成功
             $this->redirect('Admin/Index/index');
         } else {
             // 登录失败
             session(C('LOGIN_INFO'), null);
             //删除登录信息
             $this->error('登录失败!');
         }
     }
     $this->display();
 }