Skip to content

Commit 130989a

Browse files
update store and env
1 parent 06d2bd9 commit 130989a

15 files changed

Lines changed: 89 additions & 96 deletions

File tree

generator/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ module.exports = (api, options) => {
55
api.extendPackage({
66
dependencies: {
77
'axios': '^0.18.0',
8-
'vuex': '^3.1.0',
8+
"dayjs": "^1.8.19",
9+
'vuex': '^3.1.2',
910
'vuex-persistedstate': '^2.5.4',
1011
'lodash.clonedeep': '^4.5.0',
1112
'css-vars-ponyfill': '^2.1.2',

generator/templates/Authorisation/src/guards/AuthorisationGuard

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Vue from 'vue';
22

33
export default function (to, from, next) {
4-
if (!Vue.prototype.$store.getters['Authorization/isLoggedIn']) {
4+
if (!Vue.prototype.$store.getters['Authorisation/isLoggedIn']) {
55
next({name: 'login'});
66
return;
77
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
export default {
2+
namespaced: true,
3+
state: {
4+
token: null,
5+
}, mutations: {
6+
setAuthorisationToken(currentState, token) {
7+
currentState.token = token;
8+
},
9+
},
10+
getters: {
11+
isLoggedIn: state => {
12+
return state.token !== null;
13+
},
14+
getAccessToken: state => {
15+
if (state.token === null) {
16+
return '';
17+
}
18+
return state.token;
19+
},
20+
},
21+
};

generator/templates/Authorisation/src/store/modules/Authorization.js

Lines changed: 0 additions & 54 deletions
This file was deleted.
Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,14 @@
11
import Vue from 'vue';
22
import Vuex from 'vuex';
3-
import Authorization from './modules/Authorization.js';
3+
import Authorisation from './modules/Authorisation.js';
44
import createPersistedState from 'vuex-persistedstate';
55
-
66
Vue.use(Vuex);
77
export default new Vuex.Store({
88
plugins: [
9-
(store) => {
10-
window.initialState = JSON.parse(JSON.stringify(store.state));
11-
},
129
createPersistedState(),
1310
],
1411
modules: {
15-
Authorization,
12+
Authorisation,
1613
},
17-
state: {
18-
version: {
19-
major: 1,
20-
minor: 0,
21-
patch: 0,
22-
},
23-
refresh: false,
24-
},
25-
});
14+
});

generator/templates/Authorisation/src/templates/Authorisation.vue

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
<v-app class="primary" id="inspire">
44
<v-content>
55
<v-container fill-height fluid justify-center class="primary">
6-
<v-flex lg4 md6 xl3 xs12>
7-
<router-view/>
8-
</v-flex>
6+
<router-view/>
97
</v-container>
108
</v-content>
119
</v-app>
@@ -14,19 +12,19 @@
1412

1513
<script>
1614
17-
export default {
18-
components: {},
19-
watch: {},
20-
props: [],
21-
name: 'template-authorisation',
22-
data() {
23-
return {};
24-
},
25-
created() {
15+
export default {
16+
components: {},
17+
watch: {},
18+
props: [],
19+
name: 'template-authorisation',
20+
data() {
21+
return {};
22+
},
23+
created() {
2624
27-
},
28-
methods: {},
29-
};
25+
},
26+
methods: {},
27+
};
3028
</script>
3129

3230
<style scoped lang="scss">
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<template>
2+
<v-overlay :value="true">
3+
<VProgressCircular indeterminate size="64"/>
4+
</v-overlay>
5+
</template>
6+
<script>
7+
import {mapMutations} from 'vuex';
8+
9+
export default {
10+
name: 'AuthorisationCallback',
11+
methods: {
12+
...mapMutations({
13+
setAuthorisationToken: 'Authorisation/setAuthorisationToken',
14+
}),
15+
},
16+
created() {
17+
const redirect_uri = this.$route.query.redirect_uri;
18+
19+
const regex = new RegExp('[\\#&]token=([^&#]*)');
20+
const token = decodeURIComponent(regex.exec(this.$route.hash)[1]);
21+
22+
this.setAuthorisationToken(token);
23+
24+
this.$router.push({name: redirect_uri});
25+
},
26+
};
27+
</script>

generator/templates/Authorisation/src/views/InvitationAccept.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
};
7272
},
7373
created() {
74-
if (this.$store.getters['Authorization/isLoggedIn']) {
74+
if (this.$store.getters['Authorisation/isLoggedIn']) {
7575
this.$router.push({name: 'home'});
7676
}
7777
this.email = this.$route.query.email;

generator/templates/Default/_env.development.local

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
NODE_ENV=development
22
VUE_APP_ROOT_API=<%= options.rootUrl %>
3-
VUE_APP_PUBLIC_PATH=
3+
VUE_APP_PUBLIC_PATH=/
44
<%_ if (options.plugins.includes('analytics')) { _%>
55
VUE_APP_ANALYTICS=
66
<%_ } _%>

generator/templates/Default/_env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
NODE_ENV=development
22
VUE_APP_ROOT_API=//url.local/api
3-
VUE_APP_PUBLIC_PATH=
3+
VUE_APP_PUBLIC_PATH=/
44
<%_ if (options.plugins.includes('analytics')) { _%>
55
VUE_APP_ANALYTICS=
66
<%_ } _%>

0 commit comments

Comments
 (0)