Normalize FirmaEC signature style values
This commit is contained in:
@@ -6,6 +6,8 @@ const ALLOWED_QR_BACKGROUNDS = ['transparent', 'soft'];
|
||||
const ALLOWED_QR_BORDERS = ['none', 'line'];
|
||||
const LEGACY_SIGNATURE_STYLE_MAP = {
|
||||
image: 'qr',
|
||||
firmaecuador: 'firmaec',
|
||||
'firma ec': 'firmaec',
|
||||
};
|
||||
|
||||
const getSignaturePreferences = async (userId) => {
|
||||
@@ -13,7 +15,8 @@ const getSignaturePreferences = async (userId) => {
|
||||
};
|
||||
|
||||
const updateSignaturePreferences = async (userId, { signatureStyle, qrPosition, qrBackground, qrBorder, signatureImageBase64 }) => {
|
||||
const normalizedSignatureStyle = LEGACY_SIGNATURE_STYLE_MAP[String(signatureStyle || '').toLowerCase()] || signatureStyle;
|
||||
const rawSignatureStyle = String(signatureStyle || '').trim().toLowerCase();
|
||||
const normalizedSignatureStyle = LEGACY_SIGNATURE_STYLE_MAP[rawSignatureStyle] || rawSignatureStyle || 'qr';
|
||||
if (!ALLOWED_SIGNATURE_STYLES.includes(normalizedSignatureStyle)) {
|
||||
const error = new Error('Invalid signature style.');
|
||||
error.statusCode = 400;
|
||||
|
||||
Reference in New Issue
Block a user