mirror of https://github.com/nocodb/nocodb
Pranav C
2 years ago
7 changed files with 48 additions and 40 deletions
@ -1,18 +0,0 @@
|
||||
import { Router } from 'express'; |
||||
import { LICENSE_KEY } from '../../../constants'; |
||||
import Store from '../../../models/Store'; |
||||
|
||||
export const validateEE = async (_req, res, next) => { |
||||
const key = await Store.get(LICENSE_KEY); |
||||
if (!key?.value) { |
||||
return res.status(403).json({ msg: 'Not available' }); |
||||
} |
||||
next(); |
||||
}; |
||||
|
||||
const router = Router({ mergeParams: true }); |
||||
|
||||
// verify key
|
||||
// router.use((_req, _res, next) => {});
|
||||
|
||||
export default router; |
@ -0,0 +1,22 @@
|
||||
import { OrgUserRoles } from '../../../../enums/OrgUserRoles'; |
||||
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)) { |
||||
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,16 @@
|
||||
import express from 'express'; |
||||
import { LICENSE_KEY } from '../../constants'; |
||||
import Store from '../../models/Store'; |
||||
|
||||
export default function getHandler( |
||||
defaultHandler: express.Handler, |
||||
eeHandler: express.Handler |
||||
): express.Handler { |
||||
return async (...args) => { |
||||
const key = await Store.get(LICENSE_KEY); |
||||
if (!key?.value) { |
||||
return defaultHandler(...args); |
||||
} |
||||
return eeHandler(...args); |
||||
}; |
||||
} |
Loading…
Reference in new issue