Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async login(args: AuthLoginInput): Promise {
const findUser = await this.userRepository.findOne({
select: ['id', 'email', 'name', 'status', 'password'],
where: {
email: xss.filterXSS(args.email.trim().toLowerCase()),
},
// for get flatPermissions
relations: ['roles'],
});
const user = authUtil.checkAvailableUser(findUser);
const passwordIsMatch = await bcryptjs.compareSync(args.password, user.password);
if (!passwordIsMatch) return errorUtil.ERROR({ error: `User (${args.email}) Info Not Match` });
if (user.password) delete user.password;
return this.addTokenTouser(user);
}
app.use((error, _req, res, _next) => {
console.error(error.stack);
res.status(500).send(filterXSS(error.message));
});
const parseValue = (value: string, options?: IFilterXSSOptions) => {
return filterXSS(value, options)
}
formatTag(str: string): string {
if (str) {
return xss.filterXSS(str.trim().replace(/\s/g, '-'));
}
return '';
}
const serialize = (input: string, options?: IFilterXSSOptions) => {
return filterXSS(input, options)
}
if (fields && fields.kind === 'nylas') {
const nylasApi = new IntegrationsAPI();
const apiResponse = await nylasApi.nylasUpload({
...file,
erxesApiId: fields.erxesApiId,
});
return res.send(apiResponse);
}
const result = await uploadFile(file, response.upload ? true : false);
return res.send(result);
} catch (e) {
return res.status(500).send(filterXSS(e.message));
}
}
return res.status(500).send(status);
});
});
app.get('/coc-export', async (req: any, res) => {
const { query, user } = req;
const { type } = query;
try {
const { name, response } =
type === 'customers' ? await customersExport(query, user) : await companiesExport(query, user);
res.attachment(`${name}.xlsx`);
return res.send(response);
} catch (e) {
return res.end(filterXSS(e.message));
}
});