From 63168d434b6abc21bd7c85f40a0cc4d8c8fa081b Mon Sep 17 00:00:00 2001 From: Guillaume Vincent Date: Mon, 10 Oct 2016 14:15:38 +0200 Subject: [PATCH] remove current password in store --- src/components/Login.vue | 1 - src/components/Menu.vue | 12 ++++--- src/components/PasswordGenerator.vue | 66 ++++++++++++++++++++++++------------ src/components/Passwords.vue | 15 +++----- src/routes.js | 3 +- src/store.js | 34 +++---------------- 6 files changed, 64 insertions(+), 67 deletions(-) diff --git a/src/components/Login.vue b/src/components/Login.vue index a362553..2fa4717 100644 --- a/src/components/Login.vue +++ b/src/components/Login.vue @@ -106,7 +106,6 @@ .then(()=> { this.storage.save({baseURL: baseURL, email: email}); this.$store.dispatch('userAuthenticated', {email: email}); - this.$store.dispatch('loadPasswords'); this.$router.push({name: 'home'}); }) .catch(err => { diff --git a/src/components/Menu.vue b/src/components/Menu.vue index be3e9da..0a39f85 100644 --- a/src/components/Menu.vue +++ b/src/components/Menu.vue @@ -12,6 +12,7 @@ .menu-link:hover, .menu-link:focus, .menu-link:active { color: #373a3c; + text-decoration: none; } .menu-link-white { @@ -63,12 +64,15 @@ diff --git a/src/routes.js b/src/routes.js index 3a657b5..43d93c6 100644 --- a/src/routes.js +++ b/src/routes.js @@ -14,7 +14,8 @@ const routes = [ {path: '/', name: 'home', component: PasswordGenerator}, {path: '/login', name: 'login', component: Login}, {path: '/register', name: 'register', component: Register}, - {path: '/passwords', name: 'passwords', component: Passwords}, + {path: '/passwords/', name: 'passwords', component: Passwords}, + {path: '/passwords/:passwordId', name: 'password', component: PasswordGenerator}, {path: '/password/reset', name: 'passwordReset', component: PasswordReset}, {path: '/password/reset/confirm/:uid/:token', name: 'passwordResetConfirm', component: PasswordResetConfirm}, ]; diff --git a/src/store.js b/src/store.js index e853478..722ff24 100644 --- a/src/store.js +++ b/src/store.js @@ -1,48 +1,30 @@ import Vue from 'vue' import Vuex from 'vuex' import Auth from './api/auth'; -import HTTP from './api/http'; import Storage from './api/storage'; Vue.use(Vuex); const storage = new Storage(); const auth = new Auth(storage); -const passwords = new HTTP('passwords', storage); const state = { authenticated: auth.isAuthenticated(), email: '', - passwords: [], - currentPassword: {} + passwords: [] }; const mutations = { - setCurrentPassword(state, password){ - state.currentPassword = password + setPasswords(state, passwords){ + state.passwords = passwords }, logout(state){ state.authenticated = false; - state.currentPassword = { - site: '', - login: '', - options: { - uppercase: true, - lowercase: true, - numbers: true, - symbols: true, - length: 12, - counter: 1, - } - }; state.passwords = []; }, userAuthenticated(state, user){ state.authenticated = true; state.email = user.email; - }, - loadPasswords(state, passwords){ - state.passwords = passwords } }; @@ -52,21 +34,13 @@ const actions = { auth.logout(); commit('logout'); }, - loadPasswords: ({commit}) => { - if (auth.isAuthenticated()) { - passwords.all().then(response => { - commit('loadPasswords', response.data.results); - }); - } - }, - setCurrentPassword: ({commit}, password) => commit('setCurrentPassword', password), + setPasswords: ({commit}, password) => commit('setPasswords', password), }; const getters = { isAuthenticated: state => state.authenticated, isGuest: state => !state.authenticated, passwords: state => state.passwords, - currentPassword: state => state.currentPassword, email: state => state.email, baseURL: state => state.baseURL };