Bläddra i källkod

SET_VERSION should change password length

close https://github.com/lesspass/lesspass/issues/148
pull/342/head
Guillaume Vincent 7 år sedan
förälder
incheckning
53011646de
2 ändrade filer med 15 tillägg och 8 borttagningar
  1. +3
    -5
      src/store/mutations.js
  2. +12
    -3
      test/store.mutations.js

+ 3
- 5
src/store/mutations.js Visa fil

@@ -42,11 +42,9 @@ export default {
state.baseURL = baseURL;
},
[types.SET_VERSION](state, {version}){
if (state.password === null) {
state.password = {version};
} else {
state.password.version = version;
}
const length = version === 1 ? 12 : 16;
state.password.version = version;
state.password.length = length;
},
[types.LOAD_PASSWORD_FIRST_TIME](state){
const tenMinutesAgo = new Date().getTime() - 60 * 1000;


+ 12
- 3
test/store.mutations.js Visa fil

@@ -150,13 +150,22 @@ test('SET_VERSION', t => {
t.is(state.password.version, 1);
});

test('SET_VERSION password null', t => {
test('SET_VERSION 1 should modify length to 12', t => {
const SET_VERSION = mutations[types.SET_VERSION];
const state = {
password: null,
password: {length: 16, version: 2},
};
SET_VERSION(state, {version: 1});
t.is(state.password.length, 12);
});

test('SET_VERSION 2 should modify length to 16', t => {
const SET_VERSION = mutations[types.SET_VERSION];
const state = {
password: {length: 12, version: 1},
};
SET_VERSION(state, {version: 2});
t.is(state.password.version, 2);
t.is(state.password.length, 16);
});

test('LOAD_PASSWORD_FIRST_TIME 30 seconds after last use', t => {


Laddar…
Avbryt
Spara