Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// $ExpectType Hook>
validateSchema({}, ajv);
// $ExpectType Hook>
iffElse(syncTrue, [hook1, hook2], [hook3, hook4]);
// $ExpectType Hook>
iffElse(asyncTrue, [hook1, hook2], [hook3, hook4]);
// $ExpectType IffHook
iff(syncTrue, hook1, hook2);
// $ExpectType IffHook
iff(asyncTrue, hook1, hook2);
// $ExpectType Hook>
iff(syncTrue, hook1, hook2).else(hook3, hook4);
// $ExpectType Hook>
iff(asyncTrue, hook1, hook2).else(hook3, hook4);
// $ExpectType IffHook
when(syncTrue, hook1, hook2);
// $ExpectType Hook>
when(syncTrue, hook1, hook2).else(hook3, hook4);
// $ExpectType Hook>
unless(asyncTrue, hook1, hook2);
// $ExpectType Hook>
unless(syncTrue, hook1, hook2);
// $ExpectType AsyncContextFunction
some(asyncFalse, asyncTrue, syncTrue);
// $ExpectType AsyncContextFunction
every(asyncTrue, syncTrue);
});
// $ExpectType Hook>
validateSchema({}, ajv);
// $ExpectType Hook>
iffElse(syncTrue, [hook1, hook2], [hook3, hook4]);
// $ExpectType Hook>
iffElse(asyncTrue, [hook1, hook2], [hook3, hook4]);
// $ExpectType IffHook
iff(syncTrue, hook1, hook2);
// $ExpectType IffHook
iff(asyncTrue, hook1, hook2);
// $ExpectType Hook>
iff(syncTrue, hook1, hook2).else(hook3, hook4);
// $ExpectType Hook>
iff(asyncTrue, hook1, hook2).else(hook3, hook4);
// $ExpectType IffHook
when(syncTrue, hook1, hook2);
// $ExpectType Hook>
when(syncTrue, hook1, hook2).else(hook3, hook4);
// $ExpectType Hook>
unless(asyncTrue, hook1, hook2);
// $ExpectType Hook>
unless(syncTrue, hook1, hook2);
// $ExpectType AsyncContextFunction
some(asyncFalse, asyncTrue, syncTrue);
),
when(isSingleItem(),
populate({ schema: badgesSchema }),
populate({ schema: candosSchema }),
populate({ schema: userSettingsSchema })
),
thumbnails(thumbnailOptions),
cleanupPersonalData
],
get: [
populate({ schema: badgesSchema }),
populate({ schema: candosSchema }),
populate({ schema: userSettingsSchema }),
thumbnails(thumbnailOptions),
// remove personal data if its not the current authenticated user
iff(isOwnEntry(false),
cleanupPersonalData
),
iff(isOwnEntry(),
populate({ schema: userSettingsPrivateSchema })
)
],
create: [
when(isProvider('external'),
sendVerificationEmail()
),
when(isProvider('external'),
removeVerification()
),
thumbnails(thumbnailOptions),
inviteCode.after
],
}
}
};
const xssFields = ['content', 'contentExcerpt'];
//ToDo: Only let users create comments for contributions they are allowed to
module.exports = {
before: {
all: [
softDelete(),
xss({ fields: xssFields })
],
find: [
// We want to deleted comments to show up
iff(
hook => hook.params.headers && hook.params.headers.authorization,
authenticate('jwt')
),
hook => {
delete hook.params.query.deleted;
return hook;
}
],
get: [
iff(
hook => hook.params.headers && hook.params.headers.authorization,
authenticate('jwt')
)
],
create: [
authenticate('jwt'),
populate({ schema: candosSchema }),
populate({ schema: userSettingsSchema })
),
thumbnails(thumbnailOptions),
cleanupPersonalData
],
get: [
populate({ schema: badgesSchema }),
populate({ schema: candosSchema }),
populate({ schema: userSettingsSchema }),
thumbnails(thumbnailOptions),
// remove personal data if its not the current authenticated user
iff(isOwnEntry(false),
cleanupPersonalData
),
iff(isOwnEntry(),
populate({ schema: userSettingsPrivateSchema })
)
],
create: [
when(isProvider('external'),
sendVerificationEmail()
),
when(isProvider('external'),
removeVerification()
),
thumbnails(thumbnailOptions),
inviteCode.after
],
update: [
thumbnails(thumbnailOptions)
],
return function verifyReset() { // 'function' needed as we use 'this'
debug('service initialized');
const app = this;
const path = 'verifyReset';
var users;
var params;
const isAction = (...args) => hook => args.indexOf(hook.data.action) !== -1;
app.use(path, {
before: {
create: [
hooks.iff(isAction('password', 'email'), auth.verifyToken()),
hooks.iff(isAction('password', 'email'), auth.populateUser()),
],
},
create(data, params1, cb) {
debug(`service called. action=${data.action}`);
var callbackCalled = false;
var promise;
users = app.service('/users'); // here in case users service is configured after verifyReset
params = params1;
switch (data.action) {
case 'unique': // backwards compatible, fall through
case 'checkUnique':
promise = checkUniqueness(data.value, data.ownId || null, data.meta || {});
break;
case 'resend': // backwards compatible, fall through
console.log("info", "OPTIONS", options)
}
}))
this.configure(local())
this.configure(jwt())
this.service("authentication").before({
create: [
auth.hooks.authenticate(["jwt", "local"])
]
})
this.service("authManagement").before({
create: [
hooks.iff(
isAction("passwordChange", "identityChange"),
auth.hooks.authenticate(["jwt", "local"])
),
hooks.iff(
isAction("resendVerifySignup", "passwordChange", "identityChange"),
hooks.populate({
include: {
service: "users"
}
})
)
]
})
}
isEnabled(),
],
create: [
hashPassword(),
verifyHooks.addVerification(),
setDefaultRole(),
setFirstUserToRole({role: 'admin'}),
preventDisabledAdmin(),
loopItems(setUserInitials)
],
update: [
commonHooks.disallow('external')
],
patch: [
...restrict,
commonHooks.iff(commonHooks.isProvider('external'), commonHooks.preventChanges(
'email',
'isVerified',
'verifyToken',
'verifyShortToken',
'verifyExpires',
'verifyChanges',
'resetToken',
'resetShortToken',
'resetExpires'
)),
preventDisabledAdmin(),
loopItems(setUserInitials)
],
remove: [
...restrict
]
zoom: '0x1024/filters:background_color(fff)',
cover: '729x300/smart/filters:background_color(fff):upscale()',
coverPlaceholder: '243x100/smart/filters:blur(30):background_color(fff)'
}
};
const xssFields = ['content', 'contentExcerpt', 'cando.reason'];
module.exports = {
before: {
all: [
softDelete(),
xss({fields: xssFields})
],
find: [
iff(
hook => hook.params.headers && hook.params.headers.authorization,
authenticate('jwt')
),
unless(isModerator(),
excludeDisabled()
),
excludeBlacklisted(),
when(isProvider('server'),
includeAll()
),
search(),
search({
fields: ['title', 'content']
})
],
get: [
this.configure(local())
this.configure(jwt())
this.service("authentication").before({
create: [
auth.hooks.authenticate(["jwt", "local"])
]
})
this.service("authManagement").before({
create: [
hooks.iff(
isAction("passwordChange", "identityChange"),
auth.hooks.authenticate(["jwt", "local"])
),
hooks.iff(
isAction("resendVerifySignup", "passwordChange", "identityChange"),
hooks.populate({
include: {
service: "users"
}
})
)
]
})
}