Skip to content
Snippets Groups Projects
Commit a40bf58c authored by unknown's avatar unknown
Browse files

used to throw login_failed when out of consent, now oauth_outdated

parent 81c20d5d
No related branches found
No related tags found
1 merge request!14throw oauth_action_needed instead of login_failed when consent is KO
{
"version": "1.1.1",
"version": "1.1.2",
"name": "Enedis",
"type": "konnector",
"language": "node",
......
{
"name": "enedis",
"version": "1.1.1",
"version": "1.1.2",
"description": "",
"repository": {
"type": "git",
......
......@@ -98,7 +98,7 @@ async function start(fields, cozyParameters, doRetry = true) {
} catch (err) {
if (err.statusCode === 403 || err.code === 403) {
if (!fields.refresh_token) {
log('info', 'no refresh token found')
log('debug', 'no refresh token found')
throw errors.USER_ACTION_NEEDED_OAUTH_OUTDATED
} else if (doRetry) {
log('info', 'asking refresh from the stack')
......@@ -109,7 +109,7 @@ async function start(fields, cozyParameters, doRetry = true) {
`/accounts/enedisgrandlyon/${accountId}/refresh`
)
} catch (err) {
log('info', `Error during refresh ${err.message}`)
log('debug', `Error during refresh ${err.message}`)
throw errors.USER_ACTION_NEEDED_OAUTH_OUTDATED
}
log('info', 'refresh response')
......@@ -118,7 +118,11 @@ async function start(fields, cozyParameters, doRetry = true) {
fields.usage_point_id = usage_point_id
return start(fields, cozyParameters, false)
}
log('error', `Error during authentication: ${err.message}`)
if (err.message.search('ADAM-DC-0008') > 0) {
log('debug', 'No consent can be found for this customer and this usage point')
throw errors.USER_ACTION_NEEDED_OAUTH_OUTDATED
}
log('error', `Error during authentication: ${err.message}`)
throw errors.LOGIN_FAILED
} else {
log('error', 'caught an unexpected 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