Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
router.post('/enrollment', validate.body('createEnrollment'), async function (ctx) {
// Get enrollment to create from body
const enrollment: ApiPostEnrollmentObject = ctx.request.body;
// Verify all settings required for enrollment
// TODO: change this method with an end point to send the mail
if (!enrollment.test) {
if (!getServerConfig().useSMTP) {
throw new MethodNotAllowed('SMTP Server not configured.');
}
if (!getServerConfig().contact) {
throw new MethodNotAllowed('Admin contact not configured.');
}
if (!getServerConfig().webClientURL) {
throw new MethodNotAllowed('Web client URL not configured.');
}
if (!getServerConfig().proofDeskAPIIsValid) {
throw new MethodNotAllowed('ProofDesk account not configurated.');
}
}
// Create enrollment
const created = await createEnrollment(enrollment);
// Register enrollment creation event
router.post('/enrollment', validate.body('createEnrollment'), async function (ctx) {
// Get enrollment to create from body
const enrollment: ApiPostEnrollmentObject = ctx.request.body;
// Verify all settings required for enrollment
// TODO: change this method with an end point to send the mail
if (!enrollment.test) {
if (!getServerConfig().enableSMTP) {
throw new MethodNotAllowed('SMTP Server not configured.');
}
if (!getServerConfig().contact) {
throw new MethodNotAllowed('Admin contact not configured.');
}
if (!getServerConfig().webClientURL) {
throw new MethodNotAllowed('Web client URL not configured.');
}
if (!getServerConfig().enableProofDesk) {
throw new MethodNotAllowed('ProofDesk account not configured.');
}
}
// Create enrollment
const created = await createEnrollment(enrollment);
// Register enrollment creation event
const enrollment: ApiPostEnrollmentObject = ctx.request.body;
// Verify all settings required for enrollment
// TODO: change this method with an end point to send the mail
if (!enrollment.test) {
if (!getServerConfig().enableSMTP) {
throw new MethodNotAllowed('SMTP Server not configured.');
}
if (!getServerConfig().contact) {
throw new MethodNotAllowed('Admin contact not configured.');
}
if (!getServerConfig().webClientURL) {
throw new MethodNotAllowed('Web client URL not configured.');
}
if (!getServerConfig().enableProofDesk) {
throw new MethodNotAllowed('ProofDesk account not configured.');
}
}
// Create enrollment
const created = await createEnrollment(enrollment);
// Register enrollment creation event
event.register({
type: 'enrollment.create',
authorizedUserId: ctx.session.user.get('id'),
associatedTokenId: null,
associatedUserId: created.userId,
associatedKeyId: null,
data: created.id
});
throw err
}
}
if (lru) {
lru.set(source, { document, validationErrors, count: 1, jit: null })
}
} else {
document = cached.document
}
if (reply && reply.request.raw.method === 'GET') {
// let's validate we cannot do mutations here
const operationAST = getOperationAST(document, operationName)
if (operationAST.operation !== 'query') {
const err = new MethodNotAllowed()
err.errors = [new Error('Operation cannot be perfomed via a GET request')]
throw err
}
}
// minJit is 0 by default
if (cached && cached.count++ === minJit) {
cached.jit = compileQuery(schema, document, operationName)
}
if (cached && cached.jit !== null) {
const res = await cached.jit.query(root, context, variables || {})
return res
}
const execution = await execute(
router.post('/enrollment', validate.body('createEnrollment'), async function (ctx) {
// Get enrollment to create from body
const enrollment: ApiPostEnrollmentObject = ctx.request.body;
// Verify all settings required for enrollment
// TODO: change this method with an end point to send the mail
if (!enrollment.test) {
if (!getServerConfig().enableSMTP) {
throw new MethodNotAllowed('SMTP Server not configured.');
}
if (!getServerConfig().contact) {
throw new MethodNotAllowed('Admin contact not configured.');
}
if (!getServerConfig().webClientURL) {
throw new MethodNotAllowed('Web client URL not configured.');
}
if (!getServerConfig().enableProofDesk) {
throw new MethodNotAllowed('ProofDesk account not configured.');
}
}
// Create enrollment
const created = await createEnrollment(enrollment);
// Register enrollment creation event
event.register({
type: 'enrollment.create',
authorizedUserId: ctx.session.user.get('id'),
} else {
ctx.status = 501;
ctx.set('Allow', allowedArr.join(', '));
}
} else if (allowedArr.length) {
if (ctx.method === 'OPTIONS') {
ctx.status = 200;
ctx.body = '';
ctx.set('Allow', allowedArr.join(', '));
} else if (!allowed[ctx.method]) {
if (options.throw) {
var notAllowedThrowable;
if (typeof options.methodNotAllowed === 'function') {
notAllowedThrowable = options.methodNotAllowed(); // set whatever the user returns from their function
} else {
notAllowedThrowable = new HttpError.MethodNotAllowed();
}
throw notAllowedThrowable;
} else {
ctx.status = 405;
ctx.set('Allow', allowedArr.join(', '));
}
}
}
}
});
};
router.post('/enrollment', validate.body('createEnrollment'), async function (ctx) {
// Get enrollment to create from body
const enrollment: ApiPostEnrollmentObject = ctx.request.body;
// Verify all settings required for enrollment
// TODO: change this method with an end point to send the mail
if (!enrollment.test) {
if (!getServerConfig().useSMTP) {
throw new MethodNotAllowed('SMTP Server not configured.');
}
if (!getServerConfig().contact) {
throw new MethodNotAllowed('Admin contact not configured.');
}
if (!getServerConfig().webClientURL) {
throw new MethodNotAllowed('Web client URL not configured.');
}
if (!getServerConfig().proofDeskAPIIsValid) {
throw new MethodNotAllowed('ProofDesk account not configurated.');
}
}
// Create enrollment
const created = await createEnrollment(enrollment);
// Register enrollment creation event
event.register({
type: 'enrollment.create',
authorizedUserId: ctx.session.user.get('id'),
associatedTokenId: null,
associatedUserId: created.userId,
associatedKeyId: null,
router.post('/enrollment', validate.body('createEnrollment'), async function (ctx) {
// Get enrollment to create from body
const enrollment: ApiPostEnrollmentObject = ctx.request.body;
// Verify all settings required for enrollment
// TODO: change this method with an end point to send the mail
if (!enrollment.test) {
if (!getServerConfig().useSMTP) {
throw new MethodNotAllowed('SMTP Server not configured.');
}
if (!getServerConfig().contact) {
throw new MethodNotAllowed('Admin contact not configured.');
}
if (!getServerConfig().webClientURL) {
throw new MethodNotAllowed('Web client URL not configured.');
}
if (!getServerConfig().proofDeskAPIIsValid) {
throw new MethodNotAllowed('ProofDesk account not configurated.');
}
}
// Create enrollment
const created = await createEnrollment(enrollment);
// Register enrollment creation event
event.register({
type: 'enrollment.create',
authorizedUserId: ctx.session.user.get('id'),
} else {
ctx.status = 501;
ctx.set('Allow', allowedArr.join(', '));
}
} else if (allowedArr.length) {
if (ctx.method === 'OPTIONS') {
ctx.status = 200;
ctx.body = '';
ctx.set('Allow', allowedArr.join(', '));
} else if (!allowed[ctx.method]) {
if (options.throw) {
var notAllowedThrowable;
if (typeof options.methodNotAllowed === 'function') {
notAllowedThrowable = options.methodNotAllowed(); // set whatever the user returns from their function
} else {
notAllowedThrowable = new HttpError.MethodNotAllowed();
}
throw notAllowedThrowable;
} else {
ctx.status = 405;
ctx.set('Allow', allowedArr.join(', '));
}
}
}
}
});
};
methodNotAllowed: function methodNotAllowed (message) {
return new createError.MethodNotAllowed(message)
},