Skip to content
Snippets Groups Projects
Commit 3285ec7e authored by Bastien Dumont's avatar Bastien Dumont
Browse files

vendor down

parent b1500174
No related branches found
No related tags found
1 merge request!28fix: throw vendor down on auth
Pipeline #74033 passed
......@@ -202,6 +202,7 @@ async function buildAggregatedData(data, doctype) {
}
async function authenticate(login, password, baseUrl, apiAuthKey) {
log('info', 'Authenticating ...')
const authRequest = {
method: 'post',
url: baseUrl + '/connect.aspx',
......@@ -219,13 +220,14 @@ async function authenticate(login, password, baseUrl, apiAuthKey) {
const resp = await axios(authRequest)
if (resp.data.codeRetour === 100) {
return resp.data
} else {
const errorMessage = `Authentication failed. Response data: ${resp.data.libelleRetour}`
log('debug', errorMessage)
throw new Error(`code retour ko : ${resp.data.codeRetour}`)
} else if (resp.data.codeRetour === -4) {
throw new Error(errors.LOGIN_FAILED)
}
const errorMessage = `Authentication failed. Response data: ${resp?.data?.libelleRetour}`
log('error', errorMessage)
throw new Error(errors.VENDOR_DOWN)
} catch (error) {
log('debug', error.message)
log('error', error.response?.data)
Sentry.captureException(error, {
tags: {
section: 'authenticate',
......@@ -234,7 +236,7 @@ async function authenticate(login, password, baseUrl, apiAuthKey) {
compte: login,
},
})
throw new Error(errors.LOGIN_FAILED)
throw error
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment