From 9b299937da98348c2e9f7da9cec68c3744c516b2 Mon Sep 17 00:00:00 2001 From: Guillaume Vincent Date: Mon, 10 Oct 2016 14:36:28 +0200 Subject: [PATCH] add reset password confirm method in api --- src/api/auth.js | 8 ++++++++ test/auth.js | 13 +++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/api/auth.js b/src/api/auth.js index 9bef482..7e80833 100644 --- a/src/api/auth.js +++ b/src/api/auth.js @@ -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); + } } diff --git a/test/auth.js b/test/auth.js index 2cc5a57..d0c53c2 100644 --- a/test/auth.js +++ b/test/auth.js @@ -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)); }); \ No newline at end of file