Browse Source

feat(api): WIP - allow super admin access to all project

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/4134/head
Pranav C 2 years ago
parent
commit
c2de7f5a7b
  1. 8
      packages/nocodb/src/lib/meta/api/userApi/initStrategies.ts

8
packages/nocodb/src/lib/meta/api/userApi/initStrategies.ts

@ -1,3 +1,4 @@
import { OrgUserRoles } from '../../../../enums/OrgUserRoles';
import User from '../../../models/User'; import User from '../../../models/User';
import ProjectUser from '../../../models/ProjectUser'; import ProjectUser from '../../../models/ProjectUser';
import { promisify } from 'util'; import { promisify } from 'util';
@ -91,6 +92,13 @@ export function initStrategies(router): void {
...Noco.getConfig().auth.jwt.options, ...Noco.getConfig().auth.jwt.options,
}, },
async (req, jwtPayload, done) => { async (req, jwtPayload, done) => {
// todo: improve this
if (req.roles.split(',').includes(OrgUserRoles.SUPER)) {
return User.getByEmail(jwtPayload?.email).then(async (user) => {
return done(null, { ...user, roles: 'owner,creator' });
});
}
const keyVals = [jwtPayload?.email]; const keyVals = [jwtPayload?.email];
if (req.ncProjectId) { if (req.ncProjectId) {
keyVals.push(req.ncProjectId); keyVals.push(req.ncProjectId);

Loading…
Cancel
Save