@@ -13,7 +13,7 @@ import LoginPage from '../auth/LoginPage' | |||
import LogoutPage from '../auth/LogoutPage' | |||
import ForgotPasswordPage from '../auth/ForgotPasswordPage' | |||
import MultifactorAuthPage from '../auth/MultifactorAuthPage' | |||
import AppLoginPage from '../account/AppLoginPage' | |||
import AppLoginPage from '../auth/AppLoginPage' | |||
import DashboardPage from '../account/DashboardPage' | |||
import ProfilePage from '../account/profile/ProfilePage' | |||
import ActionPage from '../account/profile/ActionPage' | |||
@@ -6,6 +6,7 @@ import config from 'config'; | |||
import { util } from '../_helpers'; | |||
export const userService = { | |||
setSessionUser, | |||
login, | |||
logout, | |||
forgotPassword, | |||
@@ -1,76 +0,0 @@ | |||
<!-- Copyright (c) 2020 Bubble, Inc. All rights reserved. For personal (non-commercial) use, see license: https://getbubblenow.com/bubble-license/ --> | |||
<template> | |||
<div> | |||
<div> | |||
<hr/> | |||
<button @click="checkMeSession">{{messages.link_label_account}}</button> | |||
<hr/> | |||
<button @click="uploadBubble">{{messages.link_label_bubble}}</button> | |||
</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 (linkPrefix !== '' || linkPrefix !== '/'){ | |||
if (linkPrefix === '/applogin') { | |||
linkPrefix = '/'; | |||
} 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; | |||
} | |||
}, | |||
methods: { | |||
...mapActions('account', ['checkSession', 'validateAccount']), | |||
...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'); | |||
} | |||
}, | |||
uploadBubble(){ | |||
this.$router.push('/'); | |||
} | |||
}, | |||
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> |
@@ -0,0 +1,60 @@ | |||
<!-- Copyright (c) 2020 Bubble, Inc. All rights reserved. For personal (non-commercial) use, see license: https://getbubblenow.com/bubble-license/ --> | |||
<template> | |||
<div> | |||
{{messages.redirecting}} | |||
</div> | |||
</template> | |||
<script> | |||
import { mapState, mapGetters, mapActions } from 'vuex' | |||
import { util } from '../_helpers' | |||
export default { | |||
computed: { | |||
...mapState('account', { | |||
currentUser: state => state.user | |||
}), | |||
...mapState('users', ['user']), | |||
...mapState('system', ['messages']), | |||
}, | |||
created () { | |||
let locale = null; | |||
if (util.userLoggedIn() && util.currentUser().locale) locale = util.currentUser().locale; | |||
this.loadMessages('pre_auth', locale === null ? 'detect' : locale); | |||
let session = this.$route.query.session; | |||
let uri = this.$route.query.uri; | |||
if (!this.$route.query.hasOwnProperty('session') || typeof session === 'undefined' || session === null) { | |||
console.warn('AppLoginPage.created: session parameter is empty, sending to login page'); | |||
this.$router.push('/login'); | |||
return; | |||
} | |||
if (!this.$route.query.hasOwnProperty('uri') || (typeof uri !== 'undefined' && uri !== null && uri.length > 0 && uri[0] !== '/')) { | |||
console.warn('AppLoginPage.created: uri parameter is not empty, sending to login page'); | |||
this.$router.push('/login'); | |||
return; | |||
} | |||
let user = util.currentUser(); | |||
if (user !== null && session !== user.token) { | |||
this.logout({messages: this.messages, errors: this.errors}); | |||
} | |||
if (uri.startsWith('/appLogin')) { | |||
uri = '/'; | |||
} | |||
this.user.token = session; | |||
this.setSessionUser(this.user); | |||
this.checkSession({messages: this.messages, errors: this.errors}); | |||
this.$router.push({path: uri}); | |||
return; | |||
}, | |||
methods: { | |||
...mapActions('account', ['login', 'logout', 'checkSession']), | |||
...mapActions('users', ['setSessionUser']), | |||
...mapActions('system', ['loadSystemConfigs', 'loadMessages']), | |||
} | |||
}; | |||
</script> |