diff --git a/ruoyi-ui/src/api/login.js b/ruoyi-ui/src/api/login.js index 7b7388f..85e9b82 100644 --- a/ruoyi-ui/src/api/login.js +++ b/ruoyi-ui/src/api/login.js @@ -57,4 +57,12 @@ export function getCodeImg() { method: 'get', timeout: 20000 }) -} \ No newline at end of file +} + +export function getAccountName(data) { + return request({ + url: '/getAccountName', + method: 'get', + params: data + }) +} diff --git a/ruoyi-ui/src/permission.js b/ruoyi-ui/src/permission.js index c568979..5abf76a 100644 --- a/ruoyi-ui/src/permission.js +++ b/ruoyi-ui/src/permission.js @@ -8,7 +8,7 @@ import { isRelogin } from '@/utils/request' NProgress.configure({ showSpinner: false }) -const whiteList = ['/login', '/register'] +const whiteList = ['/login', '/register', '/LoginSso'] router.beforeEach((to, from, next) => { NProgress.start() diff --git a/ruoyi-ui/src/router/index.js b/ruoyi-ui/src/router/index.js index ac5ed9c..6219c15 100644 --- a/ruoyi-ui/src/router/index.js +++ b/ruoyi-ui/src/router/index.js @@ -46,6 +46,11 @@ export const constantRoutes = [ component: () => import('@/views/login'), hidden: true }, + { + path: '/LoginSso', + component: () => import('@/views/login-sso'), + hidden: true + }, { path: '/register', component: () => import('@/views/register'), diff --git a/ruoyi-ui/src/store/modules/user.js b/ruoyi-ui/src/store/modules/user.js index b16798c..d24810a 100644 --- a/ruoyi-ui/src/store/modules/user.js +++ b/ruoyi-ui/src/store/modules/user.js @@ -1,6 +1,6 @@ -import { login, logout, getInfo } from '@/api/login' +import { login, logout, getInfo, getAccountName } from '@/api/login' import { getToken, setToken, removeToken } from '@/utils/auth' -import {encrypt, decrypt} from '@/utils/secret' +import {encrypt, decrypt} from '@/utils/secret' const user = { state: { token: getToken(), @@ -95,6 +95,22 @@ const user = { removeToken() resolve() }) + }, + + LoginSso({ commit }, code) { + return new Promise((resolve, reject) => { + getAccountName({"code": code}).then((res) => { + if (res.code == 200) { + setToken(res.token) + commit('SET_TOKEN', res.token) + resolve() + } else { + reject(res) + } + }).catch(error => { + reject(error) + }) + }) } } } diff --git a/ruoyi-ui/src/views/login-sso.vue b/ruoyi-ui/src/views/login-sso.vue new file mode 100644 index 0000000..4221c3f --- /dev/null +++ b/ruoyi-ui/src/views/login-sso.vue @@ -0,0 +1,43 @@ + +​ +