Skip to content

Commit

Permalink
fix: handle response.body
Browse files Browse the repository at this point in the history
  • Loading branch information
jaime-ez committed Mar 4, 2024
1 parent fd801c6 commit bc211d6
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/services/authentication/http/http-authentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,16 @@ export class HttpAuthentication extends DeepstreamPlugin implements DeepstreamAu

if (this.settings.permittedStatusCodes.indexOf(response.statusCode) === -1) {
if (this.settings.reportInvalidParameters) {
if (typeof response.body === 'string' && response.body) {
callback({ isValid: false, clientData: { error: response.body }})
if (response.body) {
if (typeof response.body === 'string') {
callback({ isValid: false, clientData: { error: response.body }})
} else if (typeof response.body === 'object' && Object.keys(response.body).length > 0) {
callback({ isValid: false, clientData: {...response.body} })
} else {
callback({ isValid: false })
}
} else {
callback({ isValid: false, ...response.body })
callback({ isValid: false })
}
} else {
callback(null)
Expand Down

0 comments on commit bc211d6

Please sign in to comment.