mirror of https://github.com/nocodb/nocodb
Pranav C
2 years ago
5 changed files with 46 additions and 28 deletions
@ -1,22 +0,0 @@
|
||||
import { OrgUserRoles } from 'nocodb-sdk'; |
||||
import ApiToken from '../../../models/ApiToken'; |
||||
import { PagedResponseImpl } from '../../helpers/PagedResponse'; |
||||
|
||||
export async function apiTokenListEE(req, res) { |
||||
let fk_user_id = req.user.id; |
||||
|
||||
// if super admin get all tokens
|
||||
if (req.user.roles.includes(OrgUserRoles.SUPER_ADMIN)) { |
||||
fk_user_id = undefined; |
||||
} |
||||
|
||||
res.json( |
||||
new PagedResponseImpl( |
||||
await ApiToken.listWithCreatedBy({ ...req.query, fk_user_id }), |
||||
{ |
||||
...req.query, |
||||
count: await ApiToken.count({}), |
||||
} |
||||
) |
||||
); |
||||
} |
@ -0,0 +1,20 @@
|
||||
import { OrgUserRoles, UserType } from 'nocodb-sdk'; |
||||
import { PagedResponseImpl } from '../../meta/helpers/PagedResponse'; |
||||
import { ApiToken } from '../../models'; |
||||
|
||||
export async function apiTokenListEE(param: { user: UserType; query: any }) { |
||||
let fk_user_id = param.user.id; |
||||
|
||||
// if super admin get all tokens
|
||||
if (param.user.roles.includes(OrgUserRoles.SUPER_ADMIN)) { |
||||
fk_user_id = undefined; |
||||
} |
||||
|
||||
return new PagedResponseImpl( |
||||
await ApiToken.listWithCreatedBy({ ...param.query, fk_user_id }), |
||||
{ |
||||
...(param.query || {}), |
||||
count: await ApiToken.count({}), |
||||
} |
||||
); |
||||
} |
Loading…
Reference in new issue