request->get('url'); if ($this->auth->isLogin()) { $this->success(__("You've logged in, do not login again"), $url); } $getparam = ($url == null || $url == '') ? '?1=1' : '?url=' . urlencode($url); $this->ulmenu = []; $this->ulmenu[] = [ 'name' => '邮件短信', 'code' => 'dobyemail', 'url' => $this->request->baseFile().'/csmadmin/csmadminlogin/dobyemail' . $getparam ]; $config = get_addon_config(CsmContants::$ADDONS); //v2.1.3 适配fa.1.3.4增加手机号码调整 $this->ulmenu[] = [ 'name' => '手机短信', 'code' => 'dobymobile', 'url' => $this->request->baseFile().'/csmadmin/csmadminlogin/dobymobile' . $getparam ]; if ($config['haswxfield'] == 'Y') { $this->ulmenu[] = [ 'name' => '微信登录', 'code' => 'dobywx', 'url' => $this->request->baseFile().'/csmadmin/csmadminlogin/dobywx' . $getparam ]; } //v1.2.1 增加钉钉登录 $plugin = get_addon_info('csmding'); if ($plugin && $plugin['state']) { $getparam .= '&urlmenu='.urlencode(json_encode($this->ulmenu)); $this->ulmenu[] = [ 'name' => '钉钉登录', 'code' => 'dobydd', 'url' => $this->request->baseFile().'/csmding/ddlogin/dobydd' . $getparam ]; } $this->assign('ulmenu', $this->ulmenu); $this->assign('title', "用户登录"); $this->view->engine->layout('csmadmin/layout/default'); } public function dobyemail() { if ($this->request->isPost()) { $event = "通过邮箱登录验证码"; $ccode = $this->csmreq("ccode", true); $email = $this->csmreq("email", true); // 校验验证码 $sendccode = Session::get(CsmadminUtils::getSessionKey($email, $event)); if ($sendccode != $ccode) { $this->error('验证码错误!'); } $service = new AdminService(); $row = $service->getRowByEmail($email); if ($row) { $service->directLogin($row); $this->success(); } else { $this->error('帐号不存在,请重新登录!'); } } return $this->view->fetch(); } public function dobymobile() { if ($this->request->isPost()) { $event = "通过手机登录验证码"; $ccode = $this->csmreq("ccode", true); $mobile = $this->csmreq("mobile", true); // 校验验证码 $sendccode = Session::get(CsmadminUtils::getSessionKey($mobile, $event)); if ($sendccode != $ccode) { $this->error('验证码错误!'); } $service = new AdminService(); $row = $service->getRowByMobile($mobile); if ($row) { $service->directLogin($row); $this->success(); } else { $this->error('帐号不存在,请重新登录!'); } } return $this->view->fetch(); } public function dobywx() { if ($this->request->isPost()) { $sceneId = $this->csmreq("scene_id", true); $dao = new \app\admin\model\csmadmin\Wxscan(); $row = $dao->where("scene_id", "=", $sceneId)->find(); if ($row != null) { // 60秒验证码过期 if ((int) $sceneId < (time() - 60)) { $this->error('验证码已经过期!'); } $service = new AdminService(); $row = $service->getRowByWx($row->openid); trace($row); if ($row) { $service->directLogin($row); $this->success(); } } $this->error(''); } // copy from Csmadminapp#sendWxCodeAjax $sceneId = time(); $wxqdurl = WxUtils::qrcodeCreate($sceneId); $this->assign("wxqdurl", $wxqdurl); $this->assign("scene_id", $sceneId); return $this->view->fetch(); } public function dobydd() { // copy from Csmadminapp#modifydddialog $config = get_addon_config(CsmContants::$ADDONS); $ddappid = $config['ddappid']; $this->assign("ddappid", $ddappid); $this->assign("hosturl", $_SERVER["REQUEST_SCHEME"] . "://" . $_SERVER["SERVER_NAME"]); return $this->view->fetch(); } /** * 用户扫码后,钉钉重定向进入完成登录 */ public function dobyddtologin() { // 用户扫码后,钉钉重定向进入 $loginTmpCode = $this->csmreq("code", false); if ($loginTmpCode != null && $loginTmpCode != '') { $row = [ 'unionid' => $loginTmpCode ]; // $row = DDUtils::getUserInfoByLoginTmpCode($loginTmpCode); if ($row != null) { $service = new AdminService(); $row = $service->getRowByDduserid($row['unionid']); if($row){ $service->directLogin($row); return $this->view->fetch(); } } $this->error('帐号不存在,请重新登录!'); } } }