Merge pull request #1286 from Alfresco/dev-eromano-1281

Cannot login after logging out
This commit is contained in:
Vito 2016-12-15 10:22:22 -08:00 committed by GitHub
commit f80a92d11d
2 changed files with 51 additions and 1 deletions

View File

@ -144,6 +144,32 @@ describe('AlfrescoAuthentication', () => {
});
});
it('ticket should be deleted only after logout request is accepted', (done) => {
authService.login('fake-username', 'fake-password').subscribe(() => {
let logoutPromise = authService.logout();
expect(authService.getTicketEcm()).toBe('fake-post-ticket');
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 204
});
logoutPromise.subscribe(() => {
expect(authService.isLoggedIn()).toBe(false);
expect(authService.isEcmLoggedIn()).toBe(false);
done();
});
});
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 201,
contentType: 'application/json',
responseText: JSON.stringify({'entry': {'id': 'fake-post-ticket', 'userId': 'admin'}})
});
});
it('should return false if the user is not logged in', () => {
expect(authService.isLoggedIn()).toBe(false);
expect(authService.isEcmLoggedIn()).toBe(false);
@ -200,6 +226,30 @@ describe('AlfrescoAuthentication', () => {
});
});
it('ticket should be deleted only after logout request is accepted', (done) => {
authService.login('fake-username', 'fake-password').subscribe(() => {
let logoutPromise = authService.logout();
expect(authService.getTicketBpm()).toBe('Basic ZmFrZS11c2VybmFtZTpmYWtlLXBhc3N3b3Jk');
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200
});
logoutPromise.subscribe(() => {
expect(authService.isLoggedIn()).toBe(false);
expect(authService.isBpmLoggedIn()).toBe(false);
done();
});
});
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200
});
});
it('should return a ticket undefined after logout', (done) => {
authService.login('fake-username', 'fake-password').subscribe(() => {
authService.logout().subscribe(() => {

View File

@ -114,10 +114,10 @@ export class AlfrescoAuthenticationService {
* @returns {Observable<R>|Observable<T>}
*/
public logout() {
this.removeTicket();
return Observable.fromPromise(this.callApiLogout())
.map(res => <any> res)
.do(response => {
this.removeTicket();
this.logoutSubject.next(response);
return response;
})