|
|
@@ -0,0 +1,74 @@ |
|
|
|
<!-- Copyright (c) 2020 Bubble, Inc. All rights reserved. For personal (non-commercial) use, see license: https://getbubblenow.com/bubble-license/ --> |
|
|
|
<template> |
|
|
|
<div> |
|
|
|
<div> |
|
|
|
<hr/> |
|
|
|
<router-link :to="linkPrefix+'/me'">{{messages.link_label_account}}</router-link> |
|
|
|
<hr/> |
|
|
|
<router-link :to="linkPrefix+'/'">{{messages.link_label_bubble}}</router-link> |
|
|
|
<router-view></router-view> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
|
|
|
|
<script> |
|
|
|
import { mapState, mapGetters, mapActions } from 'vuex' |
|
|
|
import { util } from '../_helpers' |
|
|
|
|
|
|
|
export default { |
|
|
|
data() { |
|
|
|
return { |
|
|
|
linkPrefix: null, |
|
|
|
user: util.currentUser() |
|
|
|
} |
|
|
|
}, |
|
|
|
computed: { |
|
|
|
...mapState('account', { |
|
|
|
currentUser: state => state.user |
|
|
|
}), |
|
|
|
...mapState('users', ['user']), |
|
|
|
...mapState('system', ['messages', 'configs']), |
|
|
|
}, |
|
|
|
created () { |
|
|
|
linkPrefix = this.$route.path; |
|
|
|
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 = '/'; |
|
|
|
} else { |
|
|
|
console.warn('AppLoginPage.created: route path is not empty, sending to login page'); |
|
|
|
this.$router.push('/login'); |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
console.warn('AppLoginPage.created: no currentUser, sending to login page'); |
|
|
|
this.$router.push('/login'); |
|
|
|
return; |
|
|
|
} |
|
|
|
}, |
|
|
|
beforeRouteUpdate (to, from, next) { |
|
|
|
// TODO add /me verification |
|
|
|
|
|
|
|
if (user !== null && (typeof user.token !== 'undefined' && user.token !== null)) { |
|
|
|
next(); |
|
|
|
} else { |
|
|
|
next('/login'); |
|
|
|
} |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
...mapActions('account', ['checkSession', 'validateAccount']), |
|
|
|
...mapActions('system', ['loadSystemConfigs', 'loadMessages']) |
|
|
|
}, |
|
|
|
watch: { |
|
|
|
user (u) { |
|
|
|
if (u !== null && (typeof u.token !== 'undefined' && u.token !== null)) { |
|
|
|
this.checkSession({messages: this.messages, errors: this.errors}); |
|
|
|
this.$router.replace('/'); |
|
|
|
} else { |
|
|
|
this.$router.replace('/login'); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
</script> |