mirror of
https://github.com/jambonz/jambonz-webapp.git
synced 2026-07-04 19:21:58 +00:00
Trim inputs before submitting to API (all except passwords)
This commit is contained in:
@@ -265,12 +265,12 @@ const AccountForm = props => {
|
||||
}
|
||||
|
||||
const axiosData = {
|
||||
name,
|
||||
sip_realm: sipRealm || null,
|
||||
name: name.trim(),
|
||||
sip_realm: sipRealm.trim() || null,
|
||||
registration_hook: {
|
||||
url: regWebhook,
|
||||
url: regWebhook.trim(),
|
||||
method: method,
|
||||
username: user || null,
|
||||
username: user.trim() || null,
|
||||
password: password || null,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -321,17 +321,17 @@ const ApplicationForm = props => {
|
||||
|
||||
const data = {
|
||||
account_sid: accountSid,
|
||||
name,
|
||||
name: name.trim(),
|
||||
call_hook: {
|
||||
url: callWebhook,
|
||||
url: callWebhook.trim(),
|
||||
method: callWebhookMethod,
|
||||
username: callWebhookUser || null,
|
||||
username: callWebhookUser.trim() || null,
|
||||
password: callWebhookPass || null,
|
||||
},
|
||||
call_status_hook: {
|
||||
url: statusWebhook,
|
||||
url: statusWebhook.trim(),
|
||||
method: statusWebhookMethod,
|
||||
username: statusWebhookUser || null,
|
||||
username: statusWebhookUser.trim() || null,
|
||||
password: statusWebhookPass || null,
|
||||
},
|
||||
speech_synthesis_vendor: speechSynthesisVendor,
|
||||
|
||||
@@ -264,8 +264,10 @@ const PhoneNumberForm = props => {
|
||||
application_sid: application || null,
|
||||
};
|
||||
|
||||
const cleanedUpNumber = phoneNumber.trim().replace(/[\s-()+]/g,'');
|
||||
|
||||
if (props.type === 'add') {
|
||||
data.number = phoneNumber;
|
||||
data.number = cleanedUpNumber;
|
||||
data.voip_carrier_sid = sipTrunk;
|
||||
}
|
||||
|
||||
|
||||
@@ -247,11 +247,11 @@ const SipTrunkForm = props => {
|
||||
//-----------------------------------------------------------------------------
|
||||
// IP validation
|
||||
//-----------------------------------------------------------------------------
|
||||
const type = regIp.test(gateway.ip)
|
||||
const type = regIp.test(gateway.ip.trim())
|
||||
? 'ip'
|
||||
: regFqdn.test(gateway.ip)
|
||||
: regFqdn.test(gateway.ip.trim())
|
||||
? 'fqdn'
|
||||
: regFqdnTopLevel.test(gateway.ip)
|
||||
: regFqdnTopLevel.test(gateway.ip.trim())
|
||||
? 'fqdn-top-level'
|
||||
: 'invalid';
|
||||
|
||||
@@ -287,9 +287,9 @@ const SipTrunkForm = props => {
|
||||
//-----------------------------------------------------------------------------
|
||||
if (
|
||||
gateway.port && (
|
||||
!(regPort.test(gateway.port))
|
||||
|| (parseInt(gateway.port) < 0)
|
||||
|| (parseInt(gateway.port) > 65535)
|
||||
!(regPort.test(gateway.port.toString().trim()))
|
||||
|| (parseInt(gateway.port.toString().trim()) < 0)
|
||||
|| (parseInt(gateway.port.toString().trim()) > 65535)
|
||||
)
|
||||
) {
|
||||
errorMessages.push('Please provide a valid port number between 0 and 65535');
|
||||
@@ -390,8 +390,8 @@ const SipTrunkForm = props => {
|
||||
Authorization: `Bearer ${localStorage.getItem('token')}`,
|
||||
},
|
||||
data: {
|
||||
name,
|
||||
description,
|
||||
name: name.trim(),
|
||||
description: description.trim(),
|
||||
},
|
||||
});
|
||||
const voip_carrier_sid = voipCarrier.data.sid;
|
||||
@@ -429,8 +429,8 @@ const SipTrunkForm = props => {
|
||||
: `/SipGateways/${s.sip_gateway_sid}`;
|
||||
|
||||
const data = {
|
||||
ipv4: s.ip,
|
||||
port: s.port,
|
||||
ipv4: s.ip.trim(),
|
||||
port: s.port.toString().trim(),
|
||||
inbound: s.inbound,
|
||||
outbound: s.outbound,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user