metasocket-cordova/src/app/topbar/topbar.component.ts

32 lines
851 B
TypeScript

import {Component, Input, OnInit} from '@angular/core';
import {ApiService} from '../api.service';
import {AppComponent} from '../app.component';
import {ForegroundService} from '@ionic-native/foreground-service/ngx';
@Component({
selector: 'app-topbar',
templateUrl: './topbar.component.html',
styleUrls: ['./topbar.component.scss']
})
export class TopbarComponent implements OnInit {
@Input() token: string;
constructor(private apiService: ApiService, private foregroundService: ForegroundService) {
}
ngOnInit(): void {
}
logout(): void {
this.apiService.deleteAuthToken(this.apiService.getFromStorage('token')).toPromise()
.then()
.catch(
(error) => {console.log(error); }
);
this.apiService.storeData('token', null);
this.foregroundService.stop();
AppComponent.token = null;
}
}