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

Commit 4aa0876

Browse files
authored
1.5.0 (#233)
1.5.0
1 parent 3e8683b commit 4aa0876

File tree

9 files changed

+61
-4
lines changed

9 files changed

+61
-4
lines changed

.npmignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,5 @@
1717
*.DS_Store
1818
/package/
1919
/webpack-bundle-test.js
20-
/webpack.config.js
2120
/.github/
2221
/.babelrc

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22
<img title="alfresco" alt='alfresco' src='assets/alfresco.png' width="280px" height="150px"></img>
33
</p>
44

5-
Alfresco JS API
5+
# Alfresco JS API
6+
7+
<a name="1.5.0"></a>
8+
# [1.5.0](https://github.com/Alfresco/alfresco-js-api/releases/tag/1.5.0) (25-05-2017)
9+
## Features
10+
- [Ability to remember/forget username upon login/logout](https://github.com/Alfresco/alfresco-js-api/pull/225)
611

712
<a name="1.4.0"></a>
813
# [1.4.0](https://github.com/Alfresco/alfresco-js-api/releases/tag/1.4.0) (27-04-2017)

index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,7 @@ declare namespace AlfrescoApi {
543543
export interface AuthApi {
544544
new(config: AlfrescoApiConfig): AuthApi;
545545

546+
username: string;
546547
changeHost(host: string): void;
547548
login(username: string, password: string): Promise<string>;
548549
logout(): Promise<string>;

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "alfresco-js-api",
3-
"version": "1.4.0",
3+
"version": "1.5.0",
44
"description": "JavaScript client library for the Alfresco REST API",
55
"author": "Alfresco Software, Ltd.",
66
"main": "main.js",
@@ -17,7 +17,8 @@
1717
"generate": "mvn clean generate-sources",
1818
"watchify": "watchify -s AlfrescoApi main.js -o dist/alfresco-js-api.js",
1919
"tslint": "tslint -c tslint.json index.d.ts",
20-
"toc": "markdown-toc -i README.md && markdown-toc -i test/mockObjects/README.md"
20+
"toc": "markdown-toc -i README.md && markdown-toc -i test/mockObjects/README.md",
21+
"prepublish" : "npm run webpack"
2122
},
2223
"repository": {
2324
"type": "git",

src/alfrescoApi.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,18 @@ class AlfrescoApi {
8181
this.invalidateSession();
8282
});
8383

84+
this.ecmClient.on('unauthorized', ()=> {
85+
this.invalidateSession();
86+
});
87+
88+
this.ecmPrivateClient.on('unauthorized', ()=> {
89+
this.invalidateSession();
90+
});
91+
92+
this.bpmClient.on('unauthorized', ()=> {
93+
this.invalidateSession();
94+
});
95+
8496
if (this.config.provider === 'OAUTH') {
8597
this.oauth2Auth = new Oauth2Auth(this.config);
8698
this.setAuthenticationClientECMBPM(this.oauth2Auth.getAuthentication(), this.oauth2Auth.getAuthentication());

src/bpmAuth.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ class BpmAuth extends AlfrescoApiClient {
1010
*/
1111
constructor(config) {
1212
super();
13+
14+
this.username = '';
1315
this.config = config;
1416
this.ticket = undefined;
1517

@@ -43,6 +45,7 @@ class BpmAuth extends AlfrescoApiClient {
4345
* @returns {Promise} A promise that returns {new authentication ticket} if resolved and {error} if rejected.
4446
* */
4547
login(username, password) {
48+
this.username = username;
4649
this.authentications.basicAuth.username = username;
4750
this.authentications.basicAuth.password = password;
4851

@@ -98,6 +101,7 @@ class BpmAuth extends AlfrescoApiClient {
98101
* @returns {Promise} A promise that returns {new authentication ticket} if resolved and {error} if rejected.
99102
* */
100103
logout() {
104+
this.username = '';
101105
var postBody = {}, pathParams = {}, queryParams = {}, headerParams = {}, formParams = {};
102106

103107
var authNames = [];

src/ecmAuth.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class EcmAuth extends AlfrescoApiClient {
1212
constructor(config) {
1313
super();
1414

15+
this.username = '';
1516
this.config = config;
1617

1718
this.basePath = this.config.hostEcm + '/' + this.config.contextRoot + '/api/-default-/public/authentication/versions/1'; //Auth Call
@@ -36,6 +37,7 @@ class EcmAuth extends AlfrescoApiClient {
3637
* @returns {Promise} A promise that returns {new authentication ticket} if resolved and {error} if rejected.
3738
* */
3839
login(username, password) {
40+
this.username = username;
3941
this.authentications.basicAuth.username = username;
4042
this.authentications.basicAuth.password = password;
4143

@@ -104,6 +106,7 @@ class EcmAuth extends AlfrescoApiClient {
104106
* @returns {Promise} A promise that returns { authentication ticket} if resolved and {error} if rejected.
105107
* */
106108
logout() {
109+
this.username = '';
107110
var authApi = new AlfrescoAuthRestApi.AuthenticationApi(this);
108111

109112
this.promise = new Promise((resolve, reject) => {

test/bpmAuth.spec.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,22 @@ describe('Bpm Auth test', function () {
1212
this.authBpmMock = new AuthBpmMock(this.hostBpm);
1313
});
1414

15+
it('should remember username on login', () => {
16+
const auth = new BpmAuth({});
17+
auth.login('johndoe', 'password');
18+
expect(auth.username).to.be.equal('johndoe');
19+
});
20+
21+
it('should forget username on logout', () => {
22+
const auth = new BpmAuth({});
23+
24+
auth.login('johndoe', 'password');
25+
expect(auth.username).to.be.equal('johndoe');
26+
27+
auth.logout();
28+
expect(auth.username).to.be.equal('');
29+
});
30+
1531
describe('With Authentication', function () {
1632

1733
it('login should return the Ticket if all is ok', function (done) {

test/ecmAuth.spec.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,22 @@ describe('Ecm Auth test', function () {
1111
this.authEcmMock = new AuthEcmMock(this.hostEcm);
1212
});
1313

14+
it('should remember username on login', () => {
15+
const auth = new EcmAuth({});
16+
auth.login('johndoe', 'password');
17+
expect(auth.username).to.be.equal('johndoe');
18+
});
19+
20+
it('should forget username on logout', () => {
21+
const auth = new EcmAuth({});
22+
23+
auth.login('johndoe', 'password');
24+
expect(auth.username).to.be.equal('johndoe');
25+
26+
auth.logout();
27+
expect(auth.username).to.be.equal('');
28+
});
29+
1430
describe('With Authentication', function () {
1531

1632
it('login should return the Ticket if all is ok', function (done) {

0 commit comments

Comments
 (0)