mirror of
https://github.com/jambonz/jambonz-webapp.git
synced 2026-07-23 20:42:19 +00:00
faulty checks
This commit is contained in:
+16
-5
@@ -290,11 +290,22 @@ export const postPhoneNumber = (payload: Partial<PhoneNumber>) => {
|
||||
);
|
||||
};
|
||||
|
||||
export const postCarrier = (sid: string, payload: Partial<Carrier>) => {
|
||||
return postFetch<SidResponse, Partial<Carrier>>(
|
||||
`${API_SERVICE_PROVIDERS}/${sid}/VoipCarriers/`,
|
||||
payload
|
||||
);
|
||||
export const postCarrier = (
|
||||
user: UserData,
|
||||
sid: string,
|
||||
payload: Partial<Carrier>
|
||||
) => {
|
||||
if (user.scope === USER_ACCOUNT) {
|
||||
return postFetch<SidResponse, Partial<SpeechCredential>>(
|
||||
`${API_ACCOUNTS}/${user.account_sid}/VoipCarriers/`,
|
||||
payload
|
||||
);
|
||||
} else {
|
||||
return postFetch<SidResponse, Partial<Carrier>>(
|
||||
`${API_SERVICE_PROVIDERS}/${sid}/VoipCarriers/`,
|
||||
payload
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
export const postPredefinedCarrierTemplate = (
|
||||
|
||||
@@ -493,7 +493,7 @@ export const CarrierForm = ({
|
||||
smpp_inbound_password: smppInboundPass.trim() || null,
|
||||
};
|
||||
|
||||
if (carrier && carrier.data) {
|
||||
if (carrier && carrier.data && user) {
|
||||
putCarrier(
|
||||
currentServiceProvider.service_provider_sid,
|
||||
carrier.data.voip_carrier_sid,
|
||||
@@ -512,20 +512,21 @@ export const CarrierForm = ({
|
||||
toastError(error.msg);
|
||||
});
|
||||
} else {
|
||||
postCarrier(currentServiceProvider.service_provider_sid, {
|
||||
...carrierPayload,
|
||||
service_provider_sid: currentServiceProvider.service_provider_sid,
|
||||
})
|
||||
.then(({ json }) => {
|
||||
handleSipGatewayPutPost(json.sid);
|
||||
handleSmppGatewayPutPost(json.sid);
|
||||
|
||||
toastSuccess("Carrier created successfully");
|
||||
navigate(`${ROUTE_INTERNAL_CARRIERS}/${json.sid}/edit`);
|
||||
if (user)
|
||||
postCarrier(user, currentServiceProvider.service_provider_sid, {
|
||||
...carrierPayload,
|
||||
service_provider_sid: currentServiceProvider.service_provider_sid,
|
||||
})
|
||||
.catch((error) => {
|
||||
toastError(error.msg);
|
||||
});
|
||||
.then(({ json }) => {
|
||||
handleSipGatewayPutPost(json.sid);
|
||||
handleSmppGatewayPutPost(json.sid);
|
||||
|
||||
toastSuccess("Carrier created successfully");
|
||||
navigate(`${ROUTE_INTERNAL_CARRIERS}/${json.sid}/edit`);
|
||||
})
|
||||
.catch((error) => {
|
||||
toastError(error.msg);
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -95,6 +95,13 @@ export const SpeechServiceForm = ({ credential }: SpeechServiceFormProps) => {
|
||||
const handleSubmit = (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
|
||||
if (user?.scope === USER_ACCOUNT && user.account_sid === accountSid) {
|
||||
toastError(
|
||||
"You do not have permissions to make changes to these Speech Credentials"
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentServiceProvider) {
|
||||
const payload: Partial<SpeechCredential> = {
|
||||
vendor,
|
||||
@@ -121,12 +128,6 @@ export const SpeechServiceForm = ({ credential }: SpeechServiceFormProps) => {
|
||||
};
|
||||
|
||||
if (credential && credential.data && user) {
|
||||
if (user?.scope === USER_ACCOUNT && user.account_sid !== accountSid) {
|
||||
toastError(
|
||||
"You do not have permissions to make changes to these Speech Credentials"
|
||||
);
|
||||
return;
|
||||
}
|
||||
/** The backend API returns obscured secrets now so we need to make sure we don't send them back */
|
||||
/** Fields not sent back via :PUT are `service_key`, `access_key_id`, `secret_access_key` and `api_key` */
|
||||
putSpeechService(
|
||||
|
||||
@@ -40,7 +40,7 @@ export const SpeechServices = () => {
|
||||
: credentials.account_sid === null
|
||||
)
|
||||
: [];
|
||||
}, [accountSid, accounts]);
|
||||
}, [accountSid, accounts, credentials]);
|
||||
|
||||
const filteredCredentials = useFilteredResults<SpeechCredential>(
|
||||
filter,
|
||||
@@ -95,11 +95,10 @@ export const SpeechServices = () => {
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if ((user && user?.scope === USER_ACCOUNT) || accountSid) {
|
||||
if (accountSid) {
|
||||
getSpeechCredentials(
|
||||
`${API_ACCOUNTS}/${user?.account_sid || accountSid}/SpeechCredentials`
|
||||
);
|
||||
console.log(credentials);
|
||||
} else {
|
||||
if (currentServiceProvider) {
|
||||
getSpeechCredentials(
|
||||
|
||||
Reference in New Issue
Block a user