@@ -32,7 +32,8 @@ | |||||
"lodash.debounce": "^4.0.8", | "lodash.debounce": "^4.0.8", | ||||
"vue": "^2.1.10", | "vue": "^2.1.10", | ||||
"vue-router": "^2.2.0", | "vue-router": "^2.2.0", | ||||
"vuex": "^2.1.1" | |||||
"vuex": "^2.1.1", | |||||
"vuex-persistedstate": "^1.1.0" | |||||
}, | }, | ||||
"devDependencies": { | "devDependencies": { | ||||
"ava": "^0.17.0", | "ava": "^0.17.0", | ||||
@@ -8,27 +8,24 @@ const storage = new Storage(); | |||||
const auth = new Auth(storage); | const auth = new Auth(storage); | ||||
const Passwords = new HTTP('passwords', storage); | const Passwords = new HTTP('passwords', storage); | ||||
export const loadLocalStorage = ({state}) => { | |||||
Object.assign({}, state, storage.json()) | |||||
export const loadPasswordFirstTime = ({commit}) => { | |||||
commit(types.LOAD_PASSWORD_FIRST_TIME); | |||||
}; | }; | ||||
export const saveDefaultPassword = ({commit}, payload) => { | export const saveDefaultPassword = ({commit}, payload) => { | ||||
storage.save(payload); | |||||
commit(types.SET_DEFAULT_PASSWORD, payload); | commit(types.SET_DEFAULT_PASSWORD, payload); | ||||
}; | }; | ||||
export const savePassword = ({commit}, payload) => { | export const savePassword = ({commit}, payload) => { | ||||
storage.save(payload); | |||||
commit(types.SET_PASSWORD, payload); | commit(types.SET_PASSWORD, payload); | ||||
}; | }; | ||||
export const saveBaseURL = ({commit}, payload) => { | export const saveBaseURL = ({commit}, payload) => { | ||||
storage.save(payload); | |||||
commit(types.SET_BASE_URL, payload); | commit(types.SET_BASE_URL, payload); | ||||
}; | }; | ||||
export const saveVersion = ({commit}, payload) => { | export const saveVersion = ({commit}, payload) => { | ||||
commit(types.SET_BASE_URL, payload); | |||||
commit(types.SET_VERSION, payload); | |||||
}; | }; | ||||
export const login = ({commit}) => { | export const login = ({commit}) => { | ||||
@@ -3,33 +3,35 @@ import Vuex from 'vuex' | |||||
import * as actions from './actions' | import * as actions from './actions' | ||||
import * as getters from './getters' | import * as getters from './getters' | ||||
import mutations from './mutations' | import mutations from './mutations' | ||||
import createPersistedState from 'vuex-persistedstate'; | |||||
Vue.use(Vuex); | Vue.use(Vuex); | ||||
const defaultPassword = { | |||||
login: '', | |||||
site: '', | |||||
uppercase: true, | |||||
lowercase: true, | |||||
numbers: true, | |||||
symbols: true, | |||||
length: 16, | |||||
counter: 1, | |||||
version: 2 | |||||
}; | |||||
const state = { | const state = { | ||||
authenticated: false, | authenticated: false, | ||||
password: null, | |||||
password: defaultPassword, | |||||
passwords: [], | passwords: [], | ||||
defaultPassword: { | |||||
login: '', | |||||
site: '', | |||||
uppercase: true, | |||||
lowercase: true, | |||||
numbers: true, | |||||
symbols: true, | |||||
length: 16, | |||||
counter: 1, | |||||
version: 2 | |||||
}, | |||||
lastUse: new Date().getTime(), | |||||
defaultPassword: defaultPassword, | |||||
lastUse: null, | |||||
baseURL: 'https://lesspass.com', | baseURL: 'https://lesspass.com', | ||||
}; | }; | ||||
actions.loadLocalStorage({state}); | |||||
export default new Vuex.Store({ | export default new Vuex.Store({ | ||||
state, | state, | ||||
getters, | getters, | ||||
actions, | actions, | ||||
mutations, | mutations, | ||||
plugins: [createPersistedState({key: 'lesspass'})] | |||||
}); | }); |