Skip to content

Commit

Permalink
Merge pull request #179 from RabotaRu/gl-redirect
Browse files Browse the repository at this point in the history
Добавлен переход на текущую страницу после авторизации в GitLab
  • Loading branch information
rpiontik authored Feb 11, 2023
2 parents 35751c0 + af50252 commit 0c24fcd
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
24 changes: 24 additions & 0 deletions src/components/sso/SSOError.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<template>
<div style="padding: 36px">
<v-alert
style="height:auto"
dense
type="error">
Не удалось получить доступ к GitLab :(
</v-alert>
</div>
</template>

<script>
export default {
name: 'SSOError',
data() {
return {
};
}
};
</script>

<style scoped>
</style>
4 changes: 3 additions & 1 deletion src/router/index.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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: ''
Expand Down
14 changes: 13 additions & 1 deletion src/router/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`
Expand Down Expand Up @@ -118,6 +125,11 @@ const routes = [
path: '/',
redirect: { name: 'main' }
},
{
name: 'ssoerror',
path: '/sso/error',
component: SSOError
},
{
name: 'Empty',
path: '*',
Expand Down

0 comments on commit 0c24fcd

Please sign in to comment.