Sfoglia il codice sorgente

add reset password confirm method in api

pull/342/head
Guillaume Vincent 8 anni fa
parent
commit
9b299937da
2 ha cambiato i file con 21 aggiunte e 0 eliminazioni
  1. +8
    -0
      src/api/auth.js
  2. +13
    -0
      test/auth.js

+ 8
- 0
src/api/auth.js Vedi File

@@ -77,4 +77,12 @@ export default class Auth {
}
return axios.post('/api/auth/password/reset/', email, config);
}

confirmResetPassword(password, baseURL) {
const config = this.storage.json();
if (baseURL) {
config.baseURL = baseURL;
}
return axios.post('/api/auth/password/reset/confirm/', password, config);
}
}

+ 13
- 0
test/auth.js Vedi File

@@ -117,4 +117,17 @@ test('should reset a password', t => {
const auth = new Auth(storage);
nock('https://lesspass.com').post('/api/auth/password/reset/', {email}).reply(204);
t.notThrows(auth.resetPassword({email}));
});

test('should confirm reset password', t => {
var newPassword ={
uid: 'MQ',
token: '5g1-2bd69bd6f6dcd73f8124',
new_password: 'password1'
};
const localStorage = new LocalStorageMock();
const storage = new Storage(localStorage);
const auth = new Auth(storage);
nock('https://lesspass.com').post('/api/auth/password/reset/confirm/', newPassword).reply(204);
t.notThrows(auth.confirmResetPassword(newPassword));
});

Caricamento…
Annulla
Salva