Bladeren bron

sso跳转登录

yuhan 4 maanden geleden
bovenliggende
commit
67103201c7
5 gewijzigde bestanden met toevoegingen van 167 en 42 verwijderingen
  1. 17 0
      src/api/login.js
  2. 16 0
      src/config/router.config.js
  3. 84 39
      src/permission.js
  4. 29 1
      src/store/modules/user.js
  5. 21 2
      src/views/user/LoginAccount.vue

+ 17 - 0
src/api/login.js

@@ -74,6 +74,23 @@ export function thirdLogin(token,thirdType) {
 }
 
 /**
+ * iot-sso登录
+ * @param eiToken
+ * @param username
+ * @returns {*}
+ */
+export function iotSsoLogin(parameter) {
+  return axios({
+    url: `/sso/dy/tzlogin`,
+    method: 'post',
+    // headers: {
+    //   'Content-Type': 'application/json;charset=UTF-8'
+    // },
+    data: parameter,
+  })
+}
+
+/**
  * 强退其他账号
  * @param token
  * @returns {*}

+ 16 - 0
src/config/router.config.js

@@ -364,6 +364,22 @@ export const constantRouterMap = [
     ]
   },
 
+  // IoT Edge相关 修改框架
+  {
+    // ito sso登录页面路由
+    path: '/iot-sso',
+    component: BlankLayout,
+    redirect: '/iot-sso/login',
+    children: [
+      {
+        // ito sso 登录路由
+        path: 'login',
+        name: 'iot-sso-login',
+        component: () => import(/* webpackChunkName: "iot-sso.login" */ '@/views/user/iotSso/IotSsoLogin')
+      },
+    ]
+  },
+
   {
     path: '/test',
     component: BlankLayout,

File diff suppressed because it is too large
+ 84 - 39
src/permission.js


+ 29 - 1
src/store/modules/user.js

@@ -1,10 +1,12 @@
 import Vue from 'vue'
-import { login, logout, phoneLogin, thirdLogin } from "@/api/login"
+import { login, logout, phoneLogin, thirdLogin, iotSsoLogin } from "@/api/login"
 import { ACCESS_TOKEN, USER_NAME,USER_INFO,USER_AUTH,SYS_BUTTON_AUTH,UI_CACHE_DB_DICT_DATA,TENANT_ID,CACHE_INCLUDED_ROUTES } from "@/store/mutation-types"
 import { welcome } from "@/utils/util"
 import { queryPermissionsByUser } from '@/api/api'
 import { getAction } from '@/api/manage'
 
+import cookie from 'js-cookie'
+
 const user = {
   state: {
     token: '',
@@ -191,6 +193,8 @@ const user = {
             let serviceUrl = encodeURIComponent(sevice)
             window.location.href = process.env.VUE_APP_CAS_BASE_URL + '/logout?service=' + serviceUrl
           }
+          // 删除EIToken
+          cookie.remove('EIToken')
           resolve()
         }).catch(() => {
           resolve()
@@ -220,6 +224,30 @@ const user = {
         })
       })
     },
+    // IoT Edge相关 修改框架
+    // iot EIToken登录
+    IotSsoLogin({ commit }, param) {
+      return new Promise((resolve, reject) => {
+        iotSsoLogin(param).then(response => {
+          if(response.code =='200'){
+            const result = response.result
+            const userInfo = result.userInfo
+            Vue.ls.set(ACCESS_TOKEN, result.token, 7 * 24 * 60 * 60 * 1000)
+            Vue.ls.set(USER_NAME, userInfo.username, 7 * 24 * 60 * 60 * 1000)
+            Vue.ls.set(USER_INFO, userInfo, 7 * 24 * 60 * 60 * 1000)
+            commit('SET_TOKEN', result.token)
+            commit('SET_INFO', userInfo)
+            commit('SET_NAME', { username: userInfo.username,realname: userInfo.realname, welcome: welcome() })
+            commit('SET_AVATAR', userInfo.avatar)
+            resolve(response)
+          }else{
+            reject(response)
+          }
+        }).catch(error => {
+          reject(error)
+        })
+      })
+    },
     saveTenant({ commit }, id){
       Vue.ls.set(TENANT_ID, id, 7 * 24 * 60 * 60 * 1000)
       commit('SET_TENANT', id)

File diff suppressed because it is too large
+ 21 - 2
src/views/user/LoginAccount.vue