[ADF-1613] logout directive (#2393)

* logout directive

* test fixes
This commit is contained in:
Denys Vuika
2017-09-29 11:12:51 -04:00
committed by Eugenio Romano
parent 016e786531
commit b158afef2b
6 changed files with 147 additions and 36 deletions

View File

@@ -87,7 +87,7 @@
<md-icon>info_outline</md-icon>
<span>About</span>
</a>
<button md-menu-item (click)="onLogout($event)">
<button md-menu-item adf-logout>
<md-icon>exit_to_app</md-icon>
<span>Logout</span>
</button>

View File

@@ -16,14 +16,7 @@
*/
import { Component, ViewEncapsulation } from '@angular/core';
import { Router } from '@angular/router';
import {
AlfrescoAuthenticationService,
AlfrescoSettingsService,
AlfrescoTranslationService,
LogService,
StorageService
} from 'ng2-alfresco-core';
import { AlfrescoSettingsService, AlfrescoTranslationService, StorageService } from 'ng2-alfresco-core';
@Component({
selector: 'adf-app',
@@ -34,12 +27,9 @@ import {
export class AppComponent {
searchTerm: string = '';
constructor(private authService: AlfrescoAuthenticationService,
private router: Router,
private settingsService: AlfrescoSettingsService,
constructor(private settingsService: AlfrescoSettingsService,
private translateService: AlfrescoTranslationService,
private storage: StorageService,
private logService: LogService) {
private storage: StorageService) {
this.setProvider();
}
@@ -47,28 +37,6 @@ export class AppComponent {
return location.pathname === '/login' || location.pathname === '/settings';
}
onLogout(event) {
event.preventDefault();
this.authService.logout()
.subscribe(
() => {
this.navigateToLogin();
},
(error: any) => {
if (error && error.response && error.response.status === 401) {
this.navigateToLogin();
} else {
this.logService.error('An unknown error occurred while logging out', error);
this.navigateToLogin();
}
}
);
}
navigateToLogin() {
this.router.navigate(['/login']);
}
changeLanguage(lang: string) {
this.translateService.use(lang);
}