Skip to content
This repository was archived by the owner on Jun 11, 2025. It is now read-only.

Commit eb4480f

Browse files
committed
#116 fix csrf token setup
1 parent 7a2d0a8 commit eb4480f

File tree

8 files changed

+2609
-3805
lines changed

8 files changed

+2609
-3805
lines changed

dist/alfresco-js-api.js

Lines changed: 1437 additions & 2092 deletions
Large diffs are not rendered by default.

dist/alfresco-js-api.min.js

Lines changed: 20 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/alfrescoApi.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ class AlfrescoApi {
5050
this.bpmAuth = new BpmAuth(this.config);
5151
this.ecmAuth = new EcmAuth(this.config);
5252

53-
this.ecmPrivateClient = new EcmPrivateClient(this.config.hostEcm, this.config.contextRoot);
54-
this.ecmClient = new EcmClient(this.config.hostEcm, this.config.contextRoot);
55-
this.bpmClient = new BpmClient(this.config.hostBpm);
53+
this.ecmPrivateClient = new EcmPrivateClient(this.config.hostEcm, this.config.contextRoot, this.config);
54+
this.ecmClient = new EcmClient(this.config.hostEcm, this.config.contextRoot, this.config);
55+
this.bpmClient = new BpmClient(this.config.hostBpm, this.config);
5656
this.setAuthenticationClientECMBPM(this.ecmAuth.getAuthentication(), this.bpmAuth.getAuthentication());
5757

5858
this.initObjects();

src/bpmClient.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ class BpmClient extends AlfrescoApiClient {
66

77
/**
88
* @param {String} host
9+
* @param {Object} config
910
*/
10-
constructor(host) {
11+
constructor(host, config) {
1112
super();
1213

1314
this.host = host;
15+
this.config = config;
1416

1517
this.changeHost(host);
1618
}

src/ecmClient.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ class EcmClient extends AlfrescoApiClient {
77
/**
88
* @param {String} host
99
* @param {String} contextRoot
10+
* @param {Object} config
1011
*/
11-
constructor(host, contextRoot) {
12+
constructor(host, contextRoot, config) {
1213
super();
1314

1415
this.host = host;
16+
this.config = config;
1517
this.contextRoot = contextRoot;
1618

1719
this.changeHost(host);

src/ecmPrivateClient.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ class EcmClient extends AlfrescoApiClient {
77
/**
88
* @param {String} host
99
* @param {String} contextRoot
10+
* @param {Object} config
1011
*/
11-
constructor(host, contextRoot) {
12+
constructor(host, contextRoot, config) {
1213
super();
1314

1415
this.host = host;
1516
this.contextRoot = contextRoot;
17+
this.config = config;
1618

1719
this.changeHost(host);
1820
}

test/alfrescoApi.spec.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,34 @@ describe('Basic configuration test', function () {
2727
.equal('http://testServer.com:1616/strangeContextRoot/api/-default-/public/alfresco/versions/1');
2828
});
2929

30+
it('disableCsrf true parameter should be reflected in the clients', function () {
31+
var config = {
32+
hostEcm: 'http://testServer.com:1616',
33+
contextRoot: 'strangeContextRoot',
34+
disableCsrf: true
35+
};
36+
37+
this.alfrescoJsApi = new AlfrescoApi(config);
38+
39+
expect(this.alfrescoJsApi.ecmClient.isCsrfEnabled())
40+
.equal(false);
41+
expect(this.alfrescoJsApi.bpmClient.isCsrfEnabled())
42+
.equal(false);
43+
});
44+
45+
it('disableCsrf false parameter should be reflected in the clients', function () {
46+
var config = {
47+
hostEcm: 'http://testServer.com:1616',
48+
contextRoot: 'strangeContextRoot',
49+
disableCsrf: false
50+
};
51+
52+
this.alfrescoJsApi = new AlfrescoApi(config);
53+
54+
expect(this.alfrescoJsApi.ecmClient.isCsrfEnabled())
55+
.equal(true);
56+
expect(this.alfrescoJsApi.bpmClient.isCsrfEnabled())
57+
.equal(true);
58+
});
59+
3060
});

0 commit comments

Comments
 (0)