fix: update bearer to capital case and handle undefined (#7226)

This commit is contained in:
Srikanth Chekuri 2025-03-06 09:30:30 +05:30 committed by GitHub
parent cb2c492618
commit 816cae3aac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 25 additions and 18 deletions

View File

@ -9,19 +9,21 @@ const create = async (
): Promise<SuccessResponse<PayloadProps> | ErrorResponse> => {
try {
let httpConfig = {};
const username = props.username ? props.username.trim() : '';
const password = props.password ? props.password.trim() : '';
if (props.username !== '' && props.password !== '') {
if (username !== '' && password !== '') {
httpConfig = {
basic_auth: {
username: props.username,
password: props.password,
username,
password,
},
};
} else if (props.username === '' && props.password !== '') {
} else if (username === '' && password !== '') {
httpConfig = {
authorization: {
type: 'bearer',
credentials: props.password,
type: 'Bearer',
credentials: password,
},
};
}

View File

@ -9,18 +9,21 @@ const editWebhook = async (
): Promise<SuccessResponse<PayloadProps> | ErrorResponse> => {
try {
let httpConfig = {};
if (props.username !== '' && props.password !== '') {
const username = props.username ? props.username.trim() : '';
const password = props.password ? props.password.trim() : '';
if (username !== '' && password !== '') {
httpConfig = {
basic_auth: {
username: props.username,
password: props.password,
username,
password,
},
};
} else if (props.username === '' && props.password !== '') {
} else if (username === '' && password !== '') {
httpConfig = {
authorization: {
type: 'bearer',
credentials: props.password,
type: 'Bearer',
credentials: password,
},
};
}

View File

@ -9,19 +9,21 @@ const testWebhook = async (
): Promise<SuccessResponse<PayloadProps> | ErrorResponse> => {
try {
let httpConfig = {};
const username = props.username ? props.username.trim() : '';
const password = props.password ? props.password.trim() : '';
if (props.username !== '' && props.password !== '') {
if (username !== '' && password !== '') {
httpConfig = {
basic_auth: {
username: props.username,
password: props.password,
username,
password,
},
};
} else if (props.username === '' && props.password !== '') {
} else if (username === '' && password !== '') {
httpConfig = {
authorization: {
type: 'bearer',
credentials: props.password,
type: 'Bearer',
credentials: password,
},
};
}