Browse Source

mfa login working with authenticator

pull/1/head
Jonathan Cobb 4 years ago
parent
commit
b791935018
2 changed files with 18 additions and 5 deletions
  1. +5
    -4
      src/_store/account.module.js
  2. +13
    -1
      src/auth/MultifactorAuthPage.vue

+ 5
- 4
src/_store/account.module.js View File

@@ -24,13 +24,13 @@ const actions = {
if (user.token) { if (user.token) {
const landing = getLandingPage(); const landing = getLandingPage();
if (landing === null) { if (landing === null) {
router.push('/');
router.replace('/');
} else { } else {
resetLandingPage(); resetLandingPage();
router.push(landing.fullPath);
router.replace(landing.fullPath);
} }
} else if (user.multifactorAuth) { } else if (user.multifactorAuth) {
router.push('/auth');
router.replace('/auth');
} }
}, },
error => { error => {
@@ -100,7 +100,7 @@ const actions = {
commit('sendAuthenticatorCodeRequest'); commit('sendAuthenticatorCodeRequest');
userService.sendAuthenticatorCode(uuid, code, verifyOnly, messages, errors) userService.sendAuthenticatorCode(uuid, code, verifyOnly, messages, errors)
.then( .then(
policy => commit('sendAuthenticatorCodeSuccess', policy),
user => commit('sendAuthenticatorCodeSuccess', user),
error => commit('sendAuthenticatorCodeFailure', error) error => commit('sendAuthenticatorCodeFailure', error)
); );
} }
@@ -171,6 +171,7 @@ const mutations = {
state.actionStatus = { requesting: true, type: 'approve' }; state.actionStatus = { requesting: true, type: 'approve' };
}, },
sendAuthenticatorCodeSuccess(state, user) { sendAuthenticatorCodeSuccess(state, user) {
console.log("sendAuthenticatorCodeSuccess: user="+JSON.stringify(user));
state.actionStatus = { success: true, type: 'approve', result: user }; state.actionStatus = { success: true, type: 'approve', result: user };
if (user.token) state.user = user; if (user.token) state.user = user;
}, },


+ 13
- 1
src/auth/MultifactorAuthPage.vue View File

@@ -31,6 +31,7 @@


<script> <script>
import { mapState, mapActions } from 'vuex' import { mapState, mapActions } from 'vuex'
import { getLandingPage, resetLandingPage } from '../_helpers';


// convenience methods // convenience methods
import { isAuthenticator, isNotAuthenticator } from '../_store/users.module'; import { isAuthenticator, isNotAuthenticator } from '../_store/users.module';
@@ -49,6 +50,8 @@
]), ]),
isAuthenticator(val) { return window.isAuthenticator(val); }, isAuthenticator(val) { return window.isAuthenticator(val); },
isNotAuthenticator(val) { return window.isNotAuthenticator(val); }, isNotAuthenticator(val) { return window.isNotAuthenticator(val); },
getLandingPage() { return getLandingPage(); },
resetLandingPage() { return resetLandingPage(); },
submitVerification(auth) { submitVerification(auth) {
const uuid = auth.uuid; const uuid = auth.uuid;
const type = auth.type; const type = auth.type;
@@ -81,8 +84,17 @@
}, },
watch: { watch: {
user: function (u) { user: function (u) {
console.log('watch.user: received: '+JSON.stringify(u));
this.currentUser = u; this.currentUser = u;
// todo: if current user has no multifactor auth, show fatal error
if (this.currentUser.token) {
const landing = this.getLandingPage();
if (landing === null) {
this.$router.replace('/');
} else {
this.resetLandingPage();
this.$router.replace(landing.fullPath);
}
}
}, },
actionStatus (status) { actionStatus (status) {
console.log('watch.actionStatus: received: '+JSON.stringify(status)); console.log('watch.actionStatus: received: '+JSON.stringify(status));


Loading…
Cancel
Save