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


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

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

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

// convenience methods
import { isAuthenticator, isNotAuthenticator } from '../_store/users.module';
@@ -49,6 +50,8 @@
]),
isAuthenticator(val) { return window.isAuthenticator(val); },
isNotAuthenticator(val) { return window.isNotAuthenticator(val); },
getLandingPage() { return getLandingPage(); },
resetLandingPage() { return resetLandingPage(); },
submitVerification(auth) {
const uuid = auth.uuid;
const type = auth.type;
@@ -81,8 +84,17 @@
},
watch: {
user: function (u) {
console.log('watch.user: received: '+JSON.stringify(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) {
console.log('watch.actionStatus: received: '+JSON.stringify(status));


Loading…
Cancel
Save