Skip to content

Commit bc211d6

Browse files
committed
fix: handle response.body
1 parent fd801c6 commit bc211d6

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/services/authentication/http/http-authentication.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,16 @@ export class HttpAuthentication extends DeepstreamPlugin implements DeepstreamAu
9999

100100
if (this.settings.permittedStatusCodes.indexOf(response.statusCode) === -1) {
101101
if (this.settings.reportInvalidParameters) {
102-
if (typeof response.body === 'string' && response.body) {
103-
callback({ isValid: false, clientData: { error: response.body }})
102+
if (response.body) {
103+
if (typeof response.body === 'string') {
104+
callback({ isValid: false, clientData: { error: response.body }})
105+
} else if (typeof response.body === 'object' && Object.keys(response.body).length > 0) {
106+
callback({ isValid: false, clientData: {...response.body} })
107+
} else {
108+
callback({ isValid: false })
109+
}
104110
} else {
105-
callback({ isValid: false, ...response.body })
111+
callback({ isValid: false })
106112
}
107113
} else {
108114
callback(null)

0 commit comments

Comments
 (0)