Quellcode durchsuchen

Fix saving multiple profiles with same sites

Fixes: https://github.com/lesspass/lesspass/issues/279
pull/342/head
Guillaume Vincent vor 7 Jahren
Ursprung
Commit
ead22087c6
3 geänderte Dateien mit 21 neuen und 18 gelöschten Zeilen
  1. +2
    -6
      src/components/Menu.vue
  2. +11
    -10
      src/store/actions.js
  3. +8
    -2
      src/store/index.js

+ 2
- 6
src/components/Menu.vue Datei anzeigen

@@ -45,7 +45,7 @@
</div>
</template>
<script type="text/ecmascript-6">
import {mapState, mapGetters} from 'vuex';
import {mapGetters} from 'vuex';

export default {
data() {
@@ -55,7 +55,7 @@
},
methods: {
fullReload() {
this.$store.dispatch('savePassword', {password: this.defaultPassword});
this.$store.dispatch('savePassword', {password: this.$store.state.defaultPassword});
this.$router.push({name: 'home'});
},
logout() {
@@ -71,10 +71,6 @@
}
},
computed: {
...mapState([
'password',
'defaultPassword'
]),
...mapGetters([
'isAuthenticated',
'isGuest'


+ 11
- 10
src/store/actions.js Datei anzeigen

@@ -67,17 +67,18 @@ export const getPasswords = ({ commit, state }) => {
};

export const saveOrUpdatePassword = ({ commit, state }) => {
if (state.password && typeof state.password.id === "undefined") {
const site = state.password.site;
const login = state.password.login;
if (site || login) {
Password.create(state.password, state).then(response => {
savePassword({ commit }, { password: response.data });
getPasswords({ commit, state });
});
}
const site = state.password.site;
const login = state.password.login;
const existingPassword = state.passwords.find(password => {
return password.site === site && password.login === login;
});
if (existingPassword) {
const newPassword = Object.assign({}, existingPassword, state.password);
Password.update(newPassword, state).then(() => {
getPasswords({ commit, state });
});
} else {
Password.update(state.password, state).then(() => {
Password.create(state.password, state).then(() => {
getPasswords({ commit, state });
});
}


+ 8
- 2
src/store/index.js Datei anzeigen

@@ -10,8 +10,9 @@ Vue.use(Vuex);

const state = {
authenticated: false,
password: defaultPassword,
password: Object.assign({}, defaultPassword),
passwords: [],
message: "",
defaultPassword: defaultPassword,
showOptions: false,
token: null,
@@ -23,5 +24,10 @@ export default new Vuex.Store({
getters,
actions,
mutations,
plugins: [createPersistedState({ key: "lesspass" })]
plugins: [
createPersistedState({
key: "lesspass",
paths: ["token", "baseURL", "authenticated", "defaultPassword"]
})
]
});

Laden…
Abbrechen
Speichern