mirror of
https://github.com/directus/directus.git
synced 2026-01-30 23:58:15 -05:00
Add user invite
This commit is contained in:
@@ -4,6 +4,10 @@
|
||||
|
||||
## To-Do
|
||||
|
||||
Research private class property used in extended class.
|
||||
|
||||
`ItemsService.axios` is privé, maar moet publiek om 't te kunnen gebruiken in andere classes met extend, zoals users
|
||||
|
||||
- [x] Items
|
||||
- [x] Create
|
||||
- [x] Read
|
||||
@@ -14,8 +18,6 @@
|
||||
- [x] Create Comment
|
||||
- [x] Update Comment
|
||||
- [x] Delete Comment
|
||||
- [ ] Assets??? (not sure if needed)
|
||||
- [ ] Read
|
||||
- [ ] Auth
|
||||
- [ ] Login
|
||||
- [ ] Refresh
|
||||
@@ -25,18 +27,16 @@
|
||||
- [ ] oAuth
|
||||
- [ ] Get available providers
|
||||
- [ ] Login with provider
|
||||
- [ ] Collections
|
||||
- [ ] Create
|
||||
- [ ] Read
|
||||
- [ ] Update
|
||||
- [ ] Delete
|
||||
- [ ] Extensions??? (not sure if needed)
|
||||
- [ ] Read
|
||||
- [ ] Fields
|
||||
- [ ] Create
|
||||
- [ ] Read
|
||||
- [ ] Update
|
||||
- [ ] Delete
|
||||
- [x] Collections
|
||||
- [x] Create
|
||||
- [x] Read
|
||||
- [x] Update
|
||||
- [x] Delete
|
||||
- [x] Fields
|
||||
- [x] Create
|
||||
- [x] Read
|
||||
- [x] Update
|
||||
- [x] Delete
|
||||
- [x] Files
|
||||
- [x] Create
|
||||
- [x] Read
|
||||
@@ -88,7 +88,7 @@
|
||||
- [x] Read
|
||||
- [x] Update
|
||||
- [x] Delete
|
||||
- [ ] Invite
|
||||
- [x] Invite
|
||||
- [ ] Accept Invite
|
||||
- [ ] Enable TFA
|
||||
- [ ] Disable TFA
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Query, Item, Payload, Response, PrimaryKey } from '../types';
|
||||
import { AxiosInstance } from 'axios';
|
||||
|
||||
export class ItemsHandler {
|
||||
private axios: AxiosInstance;
|
||||
axios: AxiosInstance;
|
||||
private endpoint: string;
|
||||
|
||||
constructor(collection: string, axios: AxiosInstance) {
|
||||
|
||||
@@ -5,4 +5,8 @@ export class UsersHandler extends ItemsHandler {
|
||||
constructor(axios: AxiosInstance) {
|
||||
super('directus_users', axios);
|
||||
}
|
||||
|
||||
async invite(email: string | string[], role: string) {
|
||||
await this.axios.post('/users/invite', { email, role });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,4 +24,22 @@ describe('UsersHandler', () => {
|
||||
it('Extends ItemsHandler', () => {
|
||||
expect(handler).to.be.instanceOf(ItemsHandler);
|
||||
});
|
||||
|
||||
describe('invite', () => {
|
||||
it('Calls the /users/invite endpoint', async () => {
|
||||
const stub = sandbox.stub(handler.axios, 'post').resolves(Promise.resolve());
|
||||
|
||||
await handler.invite('admin@example.com', 'abc');
|
||||
expect(stub).to.have.been.calledWith('/users/invite', {
|
||||
email: 'admin@example.com',
|
||||
role: 'abc',
|
||||
});
|
||||
|
||||
await handler.invite(['admin@example.com', 'user@example.com'], 'abc');
|
||||
expect(stub).to.have.been.calledWith('/users/invite', {
|
||||
email: ['admin@example.com', 'user@example.com'],
|
||||
role: 'abc',
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user