diff --git a/src/components/sso/SSOError.vue b/src/components/sso/SSOError.vue new file mode 100644 index 00000000..fed6932e --- /dev/null +++ b/src/components/sso/SSOError.vue @@ -0,0 +1,24 @@ + + + + + diff --git a/src/router/index.js b/src/router/index.js index 896b90ca..89f5c708 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -1,5 +1,6 @@ import Vue from 'vue'; import Router from 'vue-router'; +import cookie from 'vue-cookie'; import gateway from '../idea/gateway'; import appRoutes from './routes'; @@ -36,7 +37,8 @@ if (!env.isPlugin(Plugins.idea)) { : new URLSearchParams(route.hash.substr(1)).get('code'); if (OAuthCode) { window.Vuex.dispatch('onReceivedOAuthCode', OAuthCode); - return { + const rRoute = cookie.get('return-route'); + return rRoute ? JSON.parse(rRoute) : { path: '/main', query: {}, hash: '' diff --git a/src/router/routes.js b/src/router/routes.js index 3e5777a2..4d9a612b 100644 --- a/src/router/routes.js +++ b/src/router/routes.js @@ -13,10 +13,17 @@ import AspectsMindmap from '../components/Mindmap/AspectsMindmap'; import Empty from '../components/Controls/Empty'; import DevTool from '../components/JSONata/DevTool'; import Entity from '../components/Entities/Entity'; +import SSOError from '../components/sso/SSOError'; +import cookie from 'vue-cookie'; const middleware = (route) => { if (config.oauth !== false && !window.Vuex.state.isOAuthProcess && !window.Vuex.state.access_token) { - window.location = new URL( + cookie.set('return-route', JSON.stringify({ + path: route.path, + query: route.query, + hash: route.hash + }), 1); + window.location = new URL( `/oauth/authorize?client_id=${config.oauth.APP_ID}` + '&redirect_uri=' + new URL(consts.pages.OAUTH_CALLBACK_PAGE, window.location) + `&response_type=code&state=none&scope=${config.oauth.REQUESTED_SCOPES}` @@ -118,6 +125,11 @@ const routes = [ path: '/', redirect: { name: 'main' } }, + { + name: 'ssoerror', + path: '/sso/error', + component: SSOError + }, { name: 'Empty', path: '*',