From 8011a0c1eeec0da451828cef4cf47dad148a0cab Mon Sep 17 00:00:00 2001 From: Guillaume Vincent Date: Tue, 13 Dec 2016 22:27:38 +0100 Subject: [PATCH] clean store --- src/store.js | 5 +---- src/views/Login.vue | 6 +++--- src/views/PasswordGenerator.vue | 4 ++-- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/store.js b/src/store.js index 3f829ef..83513e6 100644 --- a/src/store.js +++ b/src/store.js @@ -35,7 +35,6 @@ function getDefaultPasswordProfile(version, passwordProfile = {}) { const versionLoadedByDefault = storage.json().version || 1; const state = { authenticated: auth.isAuthenticated(), - email: '', passwordStatus: 'CLEAN', passwords: [], baseURL: 'https://lesspass.com', @@ -47,9 +46,8 @@ export const mutations = { LOGOUT(state){ state.authenticated = false; }, - USER_AUTHENTICATED(state, user){ + LOGIN(state){ state.authenticated = true; - state.email = user.email; }, SET_PASSWORDS(state, passwords){ state.passwords = passwords; @@ -148,7 +146,6 @@ const getters = { isAuthenticated: state => state.authenticated, isGuest: state => !state.authenticated, passwordStatus: state => state.passwordStatus, - email: state => state.email, version: state => state.version, }; diff --git a/src/views/Login.vue b/src/views/Login.vue index f8e2a2d..1809458 100644 --- a/src/views/Login.vue +++ b/src/views/Login.vue @@ -171,8 +171,8 @@ this.auth.login({email, password}, baseURL) .then(()=> { this.loadingSignIn = false; - this.storage.save({baseURL, email}); - this.$store.dispatch('USER_AUTHENTICATED', {email}); + this.storage.save({baseURL}); + this.$store.commit('LOGIN'); this.$router.push({name: 'home'}); }) .catch(err => { @@ -259,7 +259,7 @@ return; } - var passwordProfiles = { + const passwordProfiles = { 1: { lowercase: true, uppercase: true, diff --git a/src/views/PasswordGenerator.vue b/src/views/PasswordGenerator.vue index 5a6ac6d..7dfe9e4 100644 --- a/src/views/PasswordGenerator.vue +++ b/src/views/PasswordGenerator.vue @@ -282,7 +282,7 @@ for (let i = 0; i < passwords.length; i++) { const password = passwords[i]; if (password.site === site && password.login === login) { - this.$store.dispatch('PASSWORD_CHANGE', {password: {...password}}); + this.$store.commit('SET_PASSWORD', {password}); this.$refs.masterPassword.focus(); break; } @@ -372,7 +372,7 @@ this.generatingPassword = false; this.generatedPassword = generatedPassword; window.document.getElementById('copyPasswordButton').setAttribute('data-clipboard-text', generatedPassword); - this.$store.dispatch('PASSWORD_GENERATED'); + this.$store.commit('CHANGE_PASSWORD_STATUS', 'DIRTY'); }); }, setDefaultVersion(version){