|
|
@ -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); |
|
|
|