From c9122292f170db79a6ddb26ad0c674e4da939c10 Mon Sep 17 00:00:00 2001 From: kevinpauer Date: Sat, 19 Mar 2022 22:41:44 +0100 Subject: [PATCH] Add logout functionality --- frontend/src/app/Services/data.service.ts | 23 ++++++++++--------- .../app/Views/header/header.component.html | 4 ++++ .../src/app/Views/header/header.component.ts | 12 ++++++---- .../app/Views/profile/profile.component.ts | 9 +++----- 4 files changed, 27 insertions(+), 21 deletions(-) diff --git a/frontend/src/app/Services/data.service.ts b/frontend/src/app/Services/data.service.ts index f47d80e..bcf65c0 100644 --- a/frontend/src/app/Services/data.service.ts +++ b/frontend/src/app/Services/data.service.ts @@ -1,22 +1,23 @@ import { Injectable } from '@angular/core'; -import { HttpClient } from '@angular/common/http'; +import { HttpClient, HttpHeaders } from '@angular/common/http'; 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({ providedIn: 'root', }) export class DataService { constructor(private http: HttpClient) {} getPublicContent(): Observable { - return this.http.get(API_URL + 'all', { responseType: 'text' }); + return this.http.get(API_URL + 'portfolio', { responseType: 'text' }); } - getUserBoard(): Observable { - return this.http.get(API_URL + 'user', { responseType: 'text' }); - } - getModeratorBoard(): Observable { - return this.http.get(API_URL + 'mod', { responseType: 'text' }); - } - getAdminBoard(): Observable { - return this.http.get(API_URL + 'admin', { responseType: 'text' }); + + showStorage() { + console.log(localStorage); } } diff --git a/frontend/src/app/Views/header/header.component.html b/frontend/src/app/Views/header/header.component.html index d07d2df..d72ba56 100644 --- a/frontend/src/app/Views/header/header.component.html +++ b/frontend/src/app/Views/header/header.component.html @@ -18,5 +18,9 @@ ballot Bot Settings + diff --git a/frontend/src/app/Views/header/header.component.ts b/frontend/src/app/Views/header/header.component.ts index 7ab4cf7..e5dc48b 100644 --- a/frontend/src/app/Views/header/header.component.ts +++ b/frontend/src/app/Views/header/header.component.ts @@ -1,15 +1,19 @@ import { Component, OnInit } from '@angular/core'; +import { TokenStorageService } from 'src/app/Services/token.service'; @Component({ selector: 'app-header', templateUrl: './header.component.html', - styleUrls: ['./header.component.scss'] + styleUrls: ['./header.component.scss'], }) export class HeaderComponent implements OnInit { + constructor(private tokenStorage: TokenStorageService) {} - constructor() { } + ngOnInit(): void {} - ngOnInit(): void { + logout() { + console.log('NASE'); + this.tokenStorage.signOut(); + location.reload(); } - } diff --git a/frontend/src/app/Views/profile/profile.component.ts b/frontend/src/app/Views/profile/profile.component.ts index 29ea4ff..89b667f 100644 --- a/frontend/src/app/Views/profile/profile.component.ts +++ b/frontend/src/app/Views/profile/profile.component.ts @@ -3,13 +3,10 @@ import { Component, OnInit } from '@angular/core'; @Component({ selector: 'app-profile', templateUrl: './profile.component.html', - styleUrls: ['./profile.component.scss'] + styleUrls: ['./profile.component.scss'], }) export class ProfileComponent implements OnInit { + constructor() {} - constructor() { } - - ngOnInit(): void { - } - + ngOnInit(): void {} }