parent
321e5c9cbd
commit
9c66a14fec
@ -14,6 +14,18 @@ type Props = {
|
||||
|
||||
const description = event => {
|
||||
switch (event.name) {
|
||||
case 'api_keys.create':
|
||||
return (
|
||||
<React.Fragment>
|
||||
Created the API token <strong>{event.data.name}</strong>
|
||||
</React.Fragment>
|
||||
);
|
||||
case 'api_keys.delete':
|
||||
return (
|
||||
<React.Fragment>
|
||||
Revoked the API token <strong>{event.data.name}</strong>
|
||||
</React.Fragment>
|
||||
);
|
||||
case 'teams.create':
|
||||
return 'Created the team';
|
||||
case 'shares.create':
|
||||
|
@ -4,7 +4,7 @@ import Router from 'koa-router';
|
||||
import auth from '../middlewares/authentication';
|
||||
import pagination from './middlewares/pagination';
|
||||
import { presentApiKey } from '../presenters';
|
||||
import { ApiKey } from '../models';
|
||||
import { ApiKey, Event } from '../models';
|
||||
import policy from '../policies';
|
||||
|
||||
const { authorize } = policy;
|
||||
@ -22,6 +22,15 @@ router.post('apiKeys.create', auth(), async ctx => {
|
||||
userId: user.id,
|
||||
});
|
||||
|
||||
await Event.create({
|
||||
name: 'api_keys.create',
|
||||
modelId: key.id,
|
||||
teamId: user.teamId,
|
||||
actorId: user.id,
|
||||
data: { name },
|
||||
ip: ctx.request.ip,
|
||||
});
|
||||
|
||||
ctx.body = {
|
||||
data: presentApiKey(key),
|
||||
};
|
||||
@ -54,6 +63,15 @@ router.post('apiKeys.delete', auth(), async ctx => {
|
||||
|
||||
await key.destroy();
|
||||
|
||||
await Event.create({
|
||||
name: 'api_keys.delete',
|
||||
modelId: key.id,
|
||||
teamId: user.teamId,
|
||||
actorId: user.id,
|
||||
data: { name: key.name },
|
||||
ip: ctx.request.ip,
|
||||
});
|
||||
|
||||
ctx.body = {
|
||||
success: true,
|
||||
};
|
||||
|
@ -62,6 +62,8 @@ Event.ACTIVITY_EVENTS = [
|
||||
];
|
||||
|
||||
Event.AUDIT_EVENTS = [
|
||||
'api_keys.create',
|
||||
'api_keys.delete',
|
||||
'users.create',
|
||||
'users.promote',
|
||||
'users.demote',
|
||||
|
Reference in New Issue
Block a user