Allow SuperAdmin to disable SMS, email, and bot from dashboard settings on top of env flags. Add admin password reset with credentials SMS, plus payment discounts, notes, and payable amount handling.
27 lines
761 B
JavaScript
27 lines
761 B
JavaScript
'use strict';
|
|
|
|
const AppError = require('../../utils/AppError');
|
|
|
|
const assertCanResetPasswordAndSms = (user) => {
|
|
if (!user) throw new AppError('USER_NOT_FOUND');
|
|
|
|
const phoneNumber = String(user.phoneNumber || user.phone || '').trim();
|
|
const username = String(user.username || '').trim();
|
|
const name = String(user.name || '').trim();
|
|
|
|
if (!phoneNumber) throw new AppError('PHONE_NUMBER_REQUIRED');
|
|
if (!username) throw new AppError('VALIDATION_FAILED', null, 'Username is missing');
|
|
|
|
return { username, phoneNumber, name };
|
|
};
|
|
|
|
const isCredentialsSmsDelivered = (sendResult) => {
|
|
if (!sendResult) return false;
|
|
return sendResult.result?.skipped !== true;
|
|
};
|
|
|
|
module.exports = {
|
|
assertCanResetPasswordAndSms,
|
|
isCredentialsSmsDelivered
|
|
};
|