From f9134769f17da5b76d038974c75271f17fe88f9b Mon Sep 17 00:00:00 2001 From: Jonathan Cobb Date: Mon, 13 Jan 2020 00:30:52 -0500 Subject: [PATCH] add support for unlocking bubble --- src/_services/user.service.js | 5 +++-- src/_store/account.module.js | 6 +++++- src/_store/system.module.js | 1 + src/account/NetworkPage.vue | 1 + src/auth/LoginPage.vue | 13 +++++++++++-- 5 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/_services/user.service.js b/src/_services/user.service.js index 0668bce..29fdbf4 100644 --- a/src/_services/user.service.js +++ b/src/_services/user.service.js @@ -33,13 +33,14 @@ function setSessionUser (user) { return user; } -function login(name, password, messages, errors) { +function login(name, password, unlockKey, messages, errors) { + const unlockParam = (typeof unlockKey !== 'undefined' && unlockKey !== null) ? `?k=${unlockKey}` : ''; const requestOptions = { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ 'name': name, 'password': password }) }; - return fetch(`${config.apiUrl}/auth/login`, requestOptions) + return fetch(`${config.apiUrl}/auth/login${unlockParam}`, requestOptions) .then(handleAuthResponse(messages, errors)) .then(setSessionUser); } diff --git a/src/_store/account.module.js b/src/_store/account.module.js index 429f2dd..1f45416 100644 --- a/src/_store/account.module.js +++ b/src/_store/account.module.js @@ -38,11 +38,15 @@ const actions = { }, login({ dispatch, commit }, { user, messages, errors }) { commit('loginRequest', { name: user.name }); - userService.login(user.name, user.password, messages, errors) + userService.login(user.name, user.password, user.unlockKey, messages, errors) .then( user => { commit('loginSuccess', user); if (user.token) { + if (user.unlockKey) { + console.log('account.login: reloading system configs after unlock'); + dispatch('system/loadSystemConfigs'); + } const landing = util.getLandingPage(); if (landing === null) { router.replace('/'); diff --git a/src/_store/system.module.js b/src/_store/system.module.js index 115b58d..a4065ae 100644 --- a/src/_store/system.module.js +++ b/src/_store/system.module.js @@ -16,6 +16,7 @@ const state = { searchResults: [], status: { activating: false, searching: false, creatingEntity: false, modelSetupInProgress: false }, activated: null, + locked: null, error: null, messages: { durationToMillis: function(count, units) { diff --git a/src/account/NetworkPage.vue b/src/account/NetworkPage.vue index 8727eba..c4dd535 100644 --- a/src/account/NetworkPage.vue +++ b/src/account/NetworkPage.vue @@ -74,6 +74,7 @@

{{messages.title_network_danger_zone}}

{{ errors.first('node') }}
+
{{ errors.first('accountPlan') }}

diff --git a/src/auth/LoginPage.vue b/src/auth/LoginPage.vue index 95cf9f3..3e17431 100644 --- a/src/auth/LoginPage.vue +++ b/src/auth/LoginPage.vue @@ -6,12 +6,19 @@
Name is required
+
{{ errors.first('account') }}
Password is required
+
+ + +
Unlock Key is required
+
{{ errors.first('unlockKey') }}
+
@@ -29,6 +36,7 @@ export default { return { name: '', password: '', + unlockKey: null, submitted: false } }, @@ -43,10 +51,11 @@ export default { ...mapActions('account', ['login', 'logout']), ...mapActions('system', ['loadSystemConfigs']), handleSubmit (e) { + this.errors.clear(); this.submitted = true; - const { name, password } = this; + const { name, password, unlockKey } = this; if (name && password) { - this.login({user: {name, password}, messages: this.messages, errors: this.errors}); + this.login({user: {name, password, unlockKey}, messages: this.messages, errors: this.errors}); } } }