Browse Source

Add /me verification

pull/5/head
Svitlana 4 years ago
parent
commit
8272ec5c6a
1 changed files with 14 additions and 15 deletions
  1. +14
    -15
      src/account/AppLoginPage.vue

+ 14
- 15
src/account/AppLoginPage.vue View File

@@ -3,10 +3,9 @@
<div> <div>
<div> <div>
<hr/> <hr/>
<router-link :to="linkPrefix+'/me'">{{messages.link_label_account}}</router-link>
<div @click="checkMeSession">{{messages.link_label_account}}</div>
<hr/> <hr/>
<router-link :to="linkPrefix+'/'">{{messages.link_label_bubble}}</router-link> <router-link :to="linkPrefix+'/'">{{messages.link_label_bubble}}</router-link>
<router-view></router-view>
</div> </div>
</div> </div>
</template> </template>
@@ -32,9 +31,9 @@
created () { created () {
linkPrefix = this.$route.path; linkPrefix = this.$route.path;
if (user !== null && (typeof user.token !== 'undefined' && user.token !== null)) { if (user !== null && (typeof user.token !== 'undefined' && user.token !== null)) {
if (this.$route.path !== '' || this.$route.path !== '/'){
if (this.$route.path === '/applogin') {
this.$route.path = '/';
if (linkPrefix !== '' || linkPrefix !== '/'){
if (linkPrefix === '/applogin') {
linkPrefix = '/';
} else { } else {
console.warn('AppLoginPage.created: route path is not empty, sending to login page'); console.warn('AppLoginPage.created: route path is not empty, sending to login page');
this.$router.push('/login'); this.$router.push('/login');
@@ -47,18 +46,18 @@
return; return;
} }
}, },
beforeRouteUpdate (to, from, next) {
// TODO add /me verification

if (user !== null && (typeof user.token !== 'undefined' && user.token !== null)) {
next();
} else {
next('/login');
}
},
methods: { methods: {
...mapActions('account', ['checkSession', 'validateAccount']), ...mapActions('account', ['checkSession', 'validateAccount']),
...mapActions('system', ['loadSystemConfigs', 'loadMessages'])
...mapActions('system', ['loadSystemConfigs', 'loadMessages']),
checkMeSession () {
const user = util.currentUser();
if (user !== null && (typeof user.token !== 'undefined' && user.token !== null)) {
this.checkSession({messages: this.messages, errors: this.errors});
this.$router.push('/me');
} else {
this.$router.push('/login');
}
},
}, },
watch: { watch: {
user (u) { user (u) {


Loading…
Cancel
Save