Files
payload/src/express/middleware/authenticate.ts
Elliot DeNolf 4f2891836e fix conflicts
2020-11-20 14:42:05 -05:00

16 lines
472 B
TypeScript

import passport from 'passport';
export default (config) => {
const methods = config.collections.reduce((enabledMethods, collection) => {
if (collection.auth && collection.auth.useAPIKey) {
const collectionMethods = [...enabledMethods];
collectionMethods.unshift(`${collection.slug}-api-key`);
return collectionMethods;
}
return enabledMethods;
}, ['jwt', 'anonymous']);
return passport.authenticate(methods, { session: false });
};