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

Commit 742e4dd

Browse files
authored
Merge pull request #87 from Alfresco/dev-credentials
Fix withCredentials problem
2 parents 5358240 + 560826e commit 742e4dd

File tree

6 files changed

+151
-28
lines changed

6 files changed

+151
-28
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ var processDefinitionId = "pprocessDefinitionId_example"; // String | processDef
1818

1919
this.alfrescoJsApi.activiti.processApi.getProcessDefinitionStartForm(processDefinitionId);
2020
```
21+
- [cookies are missing #86](https://github.com/Alfresco/alfresco-js-api/issues/86)
2122

2223

2324
<a name="0.3.7"></a>

dist/alfresco-js-api.js

Lines changed: 89 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60358,11 +60358,20 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
6035860358

6035960359
/**
6036060360
* Retrieve the start form for a process definition
60361+
* @param {String} processDefinitionId processDefinitionId
6036160362
*/
60362-
this.getProcessDefinitionStartForm = function () {
60363+
this.getProcessDefinitionStartForm = function (processDefinitionId) {
6036360364
var postBody = null;
6036460365

60365-
var pathParams = {};
60366+
// verify the required parameter 'processInstanceId' is set
60367+
if (processDefinitionId == undefined || processDefinitionId == null) {
60368+
throw "Missing the required parameter 'processDefinitionId' when calling getProcessInstanceContent";
60369+
}
60370+
60371+
var pathParams = {
60372+
'processDefinitionId': processDefinitionId
60373+
};
60374+
6036660375
var queryParams = {};
6036760376
var headerParams = {};
6036860377
var formParams = {};
@@ -89827,8 +89836,11 @@ var AlfrescoApiClient = function (_ApiClient) {
8982789836
}
8982889837

8982989838
// add cookie for activiti
89830-
if (this.isBpmRequest() && this.cookie) {
89831-
request.set('Cookie', this.cookie);
89839+
if (this.isBpmRequest()) {
89840+
request._withCredentials = true;
89841+
if (this.cookie) {
89842+
request.set('Cookie', this.cookie);
89843+
}
8983289844
}
8983389845

8983489846
// set request timeout
@@ -91106,6 +91118,78 @@ var ProcessMock = function (_BaseMock) {
9110691118
}]
9110791119
});
9110891120
}
91121+
}, {
91122+
key: 'get200getProcessDefinitionStartForm',
91123+
value: function get200getProcessDefinitionStartForm() {
91124+
nock(this.host, { 'encodedQueryParams': true }).get('/activiti-app/api/enterprise/process-definitions/testProcess%3A1%3A7504/start-form').reply(200, {
91125+
'id': 2002,
91126+
'processDefinitionId': 'testProcess:1:7504',
91127+
'processDefinitionName': 'test process',
91128+
'processDefinitionKey': 'testProcess',
91129+
'tabs': [],
91130+
'fields': [{
91131+
'fieldType': 'DynamicTableRepresentation',
91132+
'id': 'label',
91133+
'name': 'Label',
91134+
'type': 'dynamic-table',
91135+
'value': null,
91136+
'required': false,
91137+
'readOnly': false,
91138+
'overrideId': false,
91139+
'colspan': 1,
91140+
'placeholder': null,
91141+
'minLength': 0,
91142+
'maxLength': 0,
91143+
'minValue': null,
91144+
'maxValue': null,
91145+
'regexPattern': null,
91146+
'optionType': null,
91147+
'hasEmptyValue': null,
91148+
'options': null,
91149+
'restUrl': null,
91150+
'restResponsePath': null,
91151+
'restIdProperty': null,
91152+
'restLabelProperty': null,
91153+
'tab': null,
91154+
'className': null,
91155+
'params': { 'existingColspan': 1, 'maxColspan': 1 },
91156+
'layout': { 'row': -1, 'column': -1, 'colspan': 2 },
91157+
'sizeX': 2,
91158+
'sizeY': 2,
91159+
'row': -1,
91160+
'col': -1,
91161+
'visibilityCondition': null,
91162+
'columnDefinitions': [{
91163+
'id': 'user',
91164+
'name': 'User',
91165+
'type': 'Dropdown',
91166+
'value': null,
91167+
'optionType': 'rest',
91168+
'options': [{ 'id': null, 'name': 'Option 1' }],
91169+
'restResponsePath': null,
91170+
'restUrl': 'https://jsonplaceholder.typicode.com/users',
91171+
'restIdProperty': 'id',
91172+
'restLabelProperty': 'name',
91173+
'amountCurrency': null,
91174+
'amountEnableFractions': false,
91175+
'required': true,
91176+
'editable': true,
91177+
'sortable': true,
91178+
'visible': true,
91179+
'endpoint': null,
91180+
'requestHeaders': null
91181+
}]
91182+
}],
91183+
'outcomes': [],
91184+
'javascriptEvents': [],
91185+
'className': '',
91186+
'style': '',
91187+
'customFieldTemplates': {},
91188+
'metadata': {},
91189+
'variables': [],
91190+
'gridsterForm': false
91191+
});
91192+
}
9110991193
}]);
9111091194

9111191195
return ProcessMock;
@@ -91243,7 +91327,7 @@ var TaskFormMock = function (_BaseMock) {
9124391327
_createClass(TaskFormMock, [{
9124491328
key: 'get200getTaskFormVariables',
9124591329
value: function get200getTaskFormVariables() {
91246-
nock(this.host, { 'encodedQueryParams': true }).get('/activiti-app/app/rest/task-forms/5028/variables').reply(200, [{ 'id': 'initiator', 'type': 'string', 'value': '1001' }]);
91330+
nock(this.host, { 'encodedQueryParams': true }).get('/activiti-app/app/rest/task-forms/5028/variables').reply(200, [{ 'id': 'initiator', 'type': 'string', 'value': '1001' }], ['Server', 'Apache-Coyote/1.1', 'set-cookie', 'ACTIVITI_REMEMBER_ME=NjdOdGwvcUtFTkVEczQyMGh4WFp5QT09OmpUL1UwdFVBTC94QTJMTFFUVFgvdFE9PQ', 'X-Content-Type-Options', 'nosniff', 'X-XSS-Protection', '1; mode=block', 'Cache-Control', 'no-cache, no-store, max-age=0, must-revalidate', 'Pragma', 'no-cache', 'Expires', '0', 'X-Frame-Options', 'SAMEORIGIN', 'Content-Type', 'application/json', 'Transfer-Encoding', 'chunked', 'Date', 'Tue, 01 Nov 2016 19:43:36 GMT', 'Connection', 'close']);
9124791331
}
9124891332
}]);
9124991333

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/alfrescoApiClient.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,11 @@ class AlfrescoApiClient extends ApiClient {
6363
}
6464

6565
// add cookie for activiti
66-
if (this.isBpmRequest() && this.cookie) {
67-
request.set('Cookie', this.cookie);
66+
if (this.isBpmRequest()) {
67+
request._withCredentials = true;
68+
if (this.cookie) {
69+
request.set('Cookie', this.cookie);
70+
}
6871
}
6972

7073
// set request timeout

test/activitiTaskFormApi.spec.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,14 @@ describe('Activiti Task Api', function () {
3434
});
3535
});
3636

37+
it('Check cookie settings', function (done) {
38+
this.taskFormMock.get200getTaskFormVariables();
39+
40+
var taskId = 5028;
41+
this.alfrescoJsApi.activiti.taskFormsApi.getTaskFormVariables(taskId).then((data)=> {
42+
expect(this.alfrescoJsApi.activiti.taskFormsApi.apiClient.cookie).equal('ACTIVITI_REMEMBER_ME=NjdOdGwvcUtFTkVEczQyMGh4WFp5QT09OmpUL1UwdFVBTC94QTJMTFFUVFgvdFE9PQ');
43+
done();
44+
});
45+
});
46+
3747
});

test/mockObjects/activiti/taskFormMock.js

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,32 @@ class TaskFormMock extends BaseMock {
1212
get200getTaskFormVariables() {
1313
nock(this.host, {'encodedQueryParams': true})
1414
.get('/activiti-app/app/rest/task-forms/5028/variables')
15-
.reply(200, [{'id': 'initiator', 'type': 'string', 'value': '1001'}]);
15+
.reply(200, [{'id':'initiator','type':'string','value':'1001'}], [ 'Server',
16+
'Apache-Coyote/1.1',
17+
'set-cookie',
18+
'ACTIVITI_REMEMBER_ME=NjdOdGwvcUtFTkVEczQyMGh4WFp5QT09OmpUL1UwdFVBTC94QTJMTFFUVFgvdFE9PQ',
19+
'X-Content-Type-Options',
20+
'nosniff',
21+
'X-XSS-Protection',
22+
'1; mode=block',
23+
'Cache-Control',
24+
'no-cache, no-store, max-age=0, must-revalidate',
25+
'Pragma',
26+
'no-cache',
27+
'Expires',
28+
'0',
29+
'X-Frame-Options',
30+
'SAMEORIGIN',
31+
'Content-Type',
32+
'application/json',
33+
'Transfer-Encoding',
34+
'chunked',
35+
'Date',
36+
'Tue, 01 Nov 2016 19:43:36 GMT',
37+
'Connection',
38+
'close' ]);
39+
40+
1641

1742
}
1843
}

0 commit comments

Comments
 (0)