diff --git a/backend/app_be/views/rest_api.py b/backend/app_be/views/rest_api.py index df04107..e6bb735 100644 --- a/backend/app_be/views/rest_api.py +++ b/backend/app_be/views/rest_api.py @@ -4,12 +4,11 @@ from django.http import JsonResponse from rest_framework.decorators import api_view from py_jwt_validator import PyJwtValidator, PyJwtException -import requests logger = logging.getLogger(__name__) -def authorize(request: requests.Request): +def authorize(request): logger.debug('Validating request: {}'.format(request)) if 'Authorization' not in request.headers: @@ -45,7 +44,7 @@ def authorize(request: requests.Request): class LoginClass: @staticmethod @api_view(['GET']) - def login(request: requests.Request): + def login(request): user_sub = authorize(request) if not user_sub: return JsonResponse({}, status=401) diff --git a/frontend/src/app/component/einstellungen/einstellungen.component.html b/frontend/src/app/component/einstellungen/einstellungen.component.html index 189ce06..7eabee9 100644 --- a/frontend/src/app/component/einstellungen/einstellungen.component.html +++ b/frontend/src/app/component/einstellungen/einstellungen.component.html @@ -1,7 +1,7 @@
-
+
Feed-Icon diff --git a/frontend/src/app/component/tweets/tweets.component.ts b/frontend/src/app/component/tweets/tweets.component.ts index 36afb20..6a2b5c0 100644 --- a/frontend/src/app/component/tweets/tweets.component.ts +++ b/frontend/src/app/component/tweets/tweets.component.ts @@ -1,4 +1,6 @@ import { Component, OnInit } from '@angular/core'; +import {AuthService} from '../../services/auth.service'; +import {HttpClient, HttpHeaders} from '@angular/common/http'; @Component({ selector: 'app-tweets', @@ -7,13 +9,24 @@ import { Component, OnInit } from '@angular/core'; }) export class TweetsComponent implements OnInit { - constructor() { } + constructor(private http: HttpClient, + private authService: AuthService) { } ngOnInit(): void { } loadMore() { console.log('TODO: Implement'); - } + const headerDict = { + 'Authorization': 'Bearer ' + this.authService.getToken(), + }; + return this.http.get('http://localhost:8000/api/login', + { + headers: new HttpHeaders(headerDict), + observe: 'response', + }) + .subscribe(data => { console.log(data); alert('Returned with code: ' + data['status']); }); + } -} + + }