Add logout functionality

This commit is contained in:
kevinpauer 2022-03-19 22:41:44 +01:00
parent 33c915f4be
commit c9122292f1
4 changed files with 27 additions and 21 deletions

View File

@ -1,22 +1,23 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http'; import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
const API_URL = 'https://aktienbot.flokaiser.com/api/user'; const API_URL = 'https://aktienbot.flokaiser.com/api/';
const httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json',
Authorization: 'Bearer',
}),
};
@Injectable({ @Injectable({
providedIn: 'root', providedIn: 'root',
}) })
export class DataService { export class DataService {
constructor(private http: HttpClient) {} constructor(private http: HttpClient) {}
getPublicContent(): Observable<any> { getPublicContent(): Observable<any> {
return this.http.get(API_URL + 'all', { responseType: 'text' }); return this.http.get(API_URL + 'portfolio', { responseType: 'text' });
} }
getUserBoard(): Observable<any> {
return this.http.get(API_URL + 'user', { responseType: 'text' }); showStorage() {
} console.log(localStorage);
getModeratorBoard(): Observable<any> {
return this.http.get(API_URL + 'mod', { responseType: 'text' });
}
getAdminBoard(): Observable<any> {
return this.http.get(API_URL + 'admin', { responseType: 'text' });
} }
} }

View File

@ -18,5 +18,9 @@
<mat-icon>ballot</mat-icon> <mat-icon>ballot</mat-icon>
<span>Bot Settings</span> <span>Bot Settings</span>
</button> </button>
<button mat-menu-item (click)="logout()">
<mat-icon>logout</mat-icon>
<span>Logout</span>
</button>
</mat-menu> </mat-menu>
</mat-toolbar> </mat-toolbar>

View File

@ -1,15 +1,19 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { TokenStorageService } from 'src/app/Services/token.service';
@Component({ @Component({
selector: 'app-header', selector: 'app-header',
templateUrl: './header.component.html', templateUrl: './header.component.html',
styleUrls: ['./header.component.scss'] styleUrls: ['./header.component.scss'],
}) })
export class HeaderComponent implements OnInit { export class HeaderComponent implements OnInit {
constructor(private tokenStorage: TokenStorageService) {}
constructor() { } ngOnInit(): void {}
ngOnInit(): void { logout() {
console.log('NASE');
this.tokenStorage.signOut();
location.reload();
} }
} }

View File

@ -3,13 +3,10 @@ import { Component, OnInit } from '@angular/core';
@Component({ @Component({
selector: 'app-profile', selector: 'app-profile',
templateUrl: './profile.component.html', templateUrl: './profile.component.html',
styleUrls: ['./profile.component.scss'] styleUrls: ['./profile.component.scss'],
}) })
export class ProfileComponent implements OnInit { export class ProfileComponent implements OnInit {
constructor() {} constructor() {}
ngOnInit(): void { ngOnInit(): void {}
}
} }