Skip to content

Commit

Permalink
better auth failure logging
Browse files Browse the repository at this point in the history
  • Loading branch information
diosmosis committed Nov 14, 2024
1 parent 6618509 commit 6adc6b2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import * as Api from './api';
import cc from './connector';
import { debugLog } from './log';
import { log } from './log';

export function getAuthType() {
return cc.newAuthTypeResponse()
Expand All @@ -22,9 +22,18 @@ export function checkForValidCreds(instanceUrl?: string, token?: string) {
instanceUrl,
token,
});
return Array.isArray(responseContent) && !!responseContent.length;

if (!Array.isArray(responseContent)) {
log('checkForValidCreds', `auth response is not an array (found ${typeof responseContent})`);
return false;
}

if (!!responseContent.length) {
log('checkForValidCreds', 'auth response is an empty array');
return false;
}
} catch (error) {
debugLog('checkForValidCreds:', 'failed to get sites ID with parameters', error.stack || error.message);
log('checkForValidCreds', 'failed to get sites ID with parameters', error.connectorErrorMessage || error.stack || error.message);
return false;
}
}
Expand Down
1 change: 1 addition & 0 deletions src/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export function throwUserError(message: string) {
cc.newUserError().setText(message).throwException();
} catch (e) {
e.isConnectorThrownError = true;
e.connectorErrorMessage = message; // so we can inspect the message later
throw e;
}
}
Expand Down

0 comments on commit 6adc6b2

Please sign in to comment.