3 const asyncHandler = require('express-async-handler');
4 const identityService = require('gitter-web-identity');
5 const StatusError = require('statuserror');
7 function ensureUserIdentityByProvider(provider) {
8 return asyncHandler(async function(req, res, next) {
9 const identity = await identityService.getIdentityForUser(req.user, provider);
12 return next(new StatusError(403, `Only ${provider} users can use this endpoint`));
19 module.exports = ensureUserIdentityByProvider;