feat(salix): refs #6427 use isProduction validation

This commit is contained in:
Javier Segarra 2024-05-23 16:45:58 +02:00
parent 4d40d825a2
commit 56444b3d33
1 changed files with 4 additions and 3 deletions

View File

@ -1,3 +1,4 @@
const isProduction = require('vn-loopback/server/boot/isProduction');
const UserError = require('vn-loopback/util/user-error');
const authCode = require('../../models/authCode');
module.exports = Self => {
@ -50,9 +51,9 @@ module.exports = Self => {
const code = await authCode(user, myOptions);
if (process.env.NODE_ENV === 'production')
await Self.app.models.Sms.send({req: {accessToken: {userId: id}}}, +userId, code);
return {code};
if (!isProduction())
return {code};
await Self.app.models.Sms.send({req: {accessToken: {userId: id}}}, +userId, code);
} catch (err) {
if (err.code === 'EMAIL_NOT_FOUND')
return;