mirror of
https://github.com/directus/directus.git
synced 2026-01-28 11:07:58 -05:00
Add tfa
This commit is contained in:
@@ -89,9 +89,10 @@ Research private class property used in extended class.
|
||||
- [x] Update
|
||||
- [x] Delete
|
||||
- [x] Invite
|
||||
- [ ] Accept Invite
|
||||
- [ ] Enable TFA
|
||||
- [ ] Disable TFA
|
||||
- [x] Accept Invite
|
||||
- [x] Enable TFA
|
||||
- [x] Disable TFA
|
||||
- [ ] Me
|
||||
- [x] Utils
|
||||
- [x] Get random string
|
||||
- [x] Hash a value
|
||||
|
||||
@@ -13,4 +13,13 @@ export class UsersHandler extends ItemsHandler {
|
||||
async acceptInvite(token: string, password: string) {
|
||||
await this.axios.post('/users/invite/accept', { token, password });
|
||||
}
|
||||
|
||||
tfa = {
|
||||
enable: async (password: string) => {
|
||||
await this.axios.post('/users/tfa/enable', { password });
|
||||
},
|
||||
disable: async (otp: string) => {
|
||||
await this.axios.post('/users/tfa/disable', { otp });
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -55,4 +55,28 @@ describe('UsersHandler', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('tfa.enable', () => {
|
||||
it('Calls the /users/tfa/enable endpoint', async () => {
|
||||
const stub = sandbox.stub(handler.axios, 'post').resolves(Promise.resolve());
|
||||
|
||||
await handler.tfa.enable('p455w0rd');
|
||||
|
||||
expect(stub).to.have.been.calledWith('/users/tfa/enable', {
|
||||
password: 'p455w0rd',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('tfa.disable', () => {
|
||||
it('Calls the /users/tfa/disable endpoint', async () => {
|
||||
const stub = sandbox.stub(handler.axios, 'post').resolves(Promise.resolve());
|
||||
|
||||
await handler.tfa.disable('351851');
|
||||
|
||||
expect(stub).to.have.been.calledWith('/users/tfa/disable', {
|
||||
otp: '351851',
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user