12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <?php
- namespace addons\csmadmin\library\business;
- use addons\csmadmin\library\CsmContants;
- use addons\csmadmin\library\service\AdminService;
- use think\Request;
- use think\Session;
- use addons\csmadmin\library\CsmTree;
- /**
- *
- * @author Chensm
- *
- */
- class IndexLoginBusiness extends ABusiness
- {
- public function moduleInit($request)
- {}
- /**
- * 根据根据用户id,和角色对应的组织&人员,重新计算authgroup
- */
- private function reCalcAdminAuthgroup($userid)
- {
- }
- public function viewFilter($request)
- {
- $sr = new Ibusinessmodel();
- $sr->trigger = true;
- $sr->triggername = "index_login";
- $config = get_addon_config(CsmContants::$ADDONS);
- $sr->jsondata = json_encode([
- 'canadminfindpassword' => $config['canadminfindpassword'],
- 'canadminregister' => $config['canadminregister']
- ]);
- return $sr;
- }
- public function actionBegin($request)
- {
- // 由于登录需要判断首次时间,而在afterlogin后首次登录状态被覆盖
- $config = get_addon_config(CsmContants::$ADDONS);
- $needupdatepsdwhenfirstlogin = $config["needupdatepsdwhenfirstlogin"];
- if ($needupdatepsdwhenfirstlogin == 'Y') {
- $username = $request->post('username');
- $service = new AdminService();
- $row = $service->getRowByUsername($username);
- if ($row != null) {
- Session::set("csmadmin_lastlogintime", $row->logintime);
- } else {
- Session::set("csmadmin_lastlogintime", time());
- }
- }
- }
- public function appEnd($response)
- {
- $request = Request::instance();
- if ($request->isAjax()) {
- $this->ajaxEnd($request);
- }
- }
- private function ajaxEnd($request)
- {
- $user = $this->getuserinfo();
- // 按部门管理,就需要根据角色重新授权
- $config = get_addon_config(CsmContants::$ADDONS);
- if ($config['canadmindepratmng'] == 'Y') {
- if ($user != null && $user['id']!=null){
- $this->reCalcAdminAuthgroup($user['id']);
- }
- }
- }
- }
|