Skip to content

Commit b0aff4a

Browse files
committed
Make credentials expired error have same code in HTTP and Bolt
1 parent 293c23a commit b0aff4a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/v1/internal/http/http-data-converter.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import {isInt} from '../../integer';
2121
import {Node, Path, PathSegment, Relationship} from '../../graph-types';
2222
import {Neo4jError, SERVICE_UNAVAILABLE} from '../../error';
2323

24+
const CREDENTIALS_EXPIRED_CODE = 'Neo.ClientError.Security.CredentialsExpired';
25+
2426
export default class HttpDataConverter {
2527

2628
encodeStatementParameters(parameters) {
@@ -46,7 +48,10 @@ export default class HttpDataConverter {
4648
if (errors) {
4749
const error = errors[0];
4850
if (error) {
49-
const code = error.code;
51+
// endpoint returns 'Neo.ClientError.Security.Forbidden' code and 'password_change' that points to another endpoint
52+
// this is different from code returned via Bolt and less descriptive
53+
// make code same as in Bolt, if password change is required
54+
const code = response.password_change ? CREDENTIALS_EXPIRED_CODE : error.code;
5055
const message = error.message;
5156
return new Neo4jError(message, code);
5257
}

0 commit comments

Comments
 (0)