Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Commit

Permalink
1.5.0 (#233)
Browse files Browse the repository at this point in the history
1.5.0
  • Loading branch information
eromano committed May 25, 2017
1 parent 3e8683b commit 4aa0876
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 4 deletions.
1 change: 0 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,5 @@
*.DS_Store
/package/
/webpack-bundle-test.js
/webpack.config.js
/.github/
/.babelrc
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
<img title="alfresco" alt='alfresco' src='assets/alfresco.png' width="280px" height="150px"></img>
</p>

Alfresco JS API
# Alfresco JS API

<a name="1.5.0"></a>
# [1.5.0](https://github.com/Alfresco/alfresco-js-api/releases/tag/1.5.0) (25-05-2017)
## Features
- [Ability to remember/forget username upon login/logout](https://github.com/Alfresco/alfresco-js-api/pull/225)

<a name="1.4.0"></a>
# [1.4.0](https://github.com/Alfresco/alfresco-js-api/releases/tag/1.4.0) (27-04-2017)
Expand Down
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ declare namespace AlfrescoApi {
export interface AuthApi {
new(config: AlfrescoApiConfig): AuthApi;

username: string;
changeHost(host: string): void;
login(username: string, password: string): Promise<string>;
logout(): Promise<string>;
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "alfresco-js-api",
"version": "1.4.0",
"version": "1.5.0",
"description": "JavaScript client library for the Alfresco REST API",
"author": "Alfresco Software, Ltd.",
"main": "main.js",
Expand All @@ -17,7 +17,8 @@
"generate": "mvn clean generate-sources",
"watchify": "watchify -s AlfrescoApi main.js -o dist/alfresco-js-api.js",
"tslint": "tslint -c tslint.json index.d.ts",
"toc": "markdown-toc -i README.md && markdown-toc -i test/mockObjects/README.md"
"toc": "markdown-toc -i README.md && markdown-toc -i test/mockObjects/README.md",
"prepublish" : "npm run webpack"
},
"repository": {
"type": "git",
Expand Down
12 changes: 12 additions & 0 deletions src/alfrescoApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,18 @@ class AlfrescoApi {
this.invalidateSession();
});

this.ecmClient.on('unauthorized', ()=> {
this.invalidateSession();
});

this.ecmPrivateClient.on('unauthorized', ()=> {
this.invalidateSession();
});

this.bpmClient.on('unauthorized', ()=> {
this.invalidateSession();
});

if (this.config.provider === 'OAUTH') {
this.oauth2Auth = new Oauth2Auth(this.config);
this.setAuthenticationClientECMBPM(this.oauth2Auth.getAuthentication(), this.oauth2Auth.getAuthentication());
Expand Down
4 changes: 4 additions & 0 deletions src/bpmAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class BpmAuth extends AlfrescoApiClient {
*/
constructor(config) {
super();

this.username = '';
this.config = config;
this.ticket = undefined;

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

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

var authNames = [];
Expand Down
3 changes: 3 additions & 0 deletions src/ecmAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class EcmAuth extends AlfrescoApiClient {
constructor(config) {
super();

this.username = '';
this.config = config;

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

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

this.promise = new Promise((resolve, reject) => {
Expand Down
16 changes: 16 additions & 0 deletions test/bpmAuth.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,22 @@ describe('Bpm Auth test', function () {
this.authBpmMock = new AuthBpmMock(this.hostBpm);
});

it('should remember username on login', () => {
const auth = new BpmAuth({});
auth.login('johndoe', 'password');
expect(auth.username).to.be.equal('johndoe');
});

it('should forget username on logout', () => {
const auth = new BpmAuth({});

auth.login('johndoe', 'password');
expect(auth.username).to.be.equal('johndoe');

auth.logout();
expect(auth.username).to.be.equal('');
});

describe('With Authentication', function () {

it('login should return the Ticket if all is ok', function (done) {
Expand Down
16 changes: 16 additions & 0 deletions test/ecmAuth.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,22 @@ describe('Ecm Auth test', function () {
this.authEcmMock = new AuthEcmMock(this.hostEcm);
});

it('should remember username on login', () => {
const auth = new EcmAuth({});
auth.login('johndoe', 'password');
expect(auth.username).to.be.equal('johndoe');
});

it('should forget username on logout', () => {
const auth = new EcmAuth({});

auth.login('johndoe', 'password');
expect(auth.username).to.be.equal('johndoe');

auth.logout();
expect(auth.username).to.be.equal('');
});

describe('With Authentication', function () {

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

0 comments on commit 4aa0876

Please sign in to comment.