123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- defined('BASEPATH') OR exit('No direct script access allowed');
- require_once('MyBaseController.php');
- class Account extends MyBaseController {
- public function login()
- {
- if($this->session->userinfo){
- $this->redirect('/Home/index');
- }else{
- $this->load->view('login');
- }
- }
- public function logout()
- {
- $this->load->library('session');
- $this->session->userinfo = null;
- $this->redirect('login', 0, '退出成功');
- }
- public function checkLogin(){
- $accountName = $this->input->post('Username');
- $password = $this->input->post('Password');
- if(!$accountName || !$password){
- $this->error('账号密码不能为空');
- }
- $url = $this->config->item('api_url2')."api/v1/User/yhCheckLogin";
- $ret = curl_post($url,[
- 'accountName' => $accountName,
- 'password' => aes_encrypt($password)
- ]);
- $ret = json_decode($ret,true);
- if(!$ret){
- $this->error('登录失败');
- }
- if($ret['code'] != 0){
- $this->error($ret['message']);
- }
- $userinfo = [
- 'userId' => $ret['data']['userId'],
- 'realName' => $ret['data']['user']['realName'],
- 'token' => $ret['data']['token'],
- 'orgId' => isset($ret['data']['orgList'])?$ret['data']['orgList'][0]['orgId']:0,
- 'orgName' => isset($ret['data']['orgList'])?$ret['data']['orgList'][0]['name']:'',
- 'user' => $ret['data']['user'],
- 'roleList' => $ret['data']['roleList'],
- 'deptList' => $ret['data']['deptList'],
- 'orgList' => $ret['data']['orgList'],
- 'rules' => $ret['data']['rules']
- ];
- $this->session->userinfo = $userinfo;
- $this->success('登录成功');
- }
- }
|