diff --git a/backend/app_be/views/rest_api.py b/backend/app_be/views/rest_api.py index a411f67..c4b7c5a 100644 --- a/backend/app_be/views/rest_api.py +++ b/backend/app_be/views/rest_api.py @@ -24,10 +24,11 @@ class LoginClass: def login(request:requests.Request): logger.debug('Validating request: {}'.format(request)) - print(request.headers) - print(request.data) - bearer = request.headers['Authorization'] + + if len(bearer.split()) < 2: + return JsonResponse({},status=401) + jwt = bearer.split()[1] print(jwt) @@ -36,24 +37,8 @@ class LoginClass: PyJwtValidator(jwt) except PyJwtException as e: print(f"Exception caught. Error: {e}") + logger.error(f"Exception caught. Error: {e}") return JsonResponse({},status=401) - return JsonResponse({'Result': 'success'}, safe=False, status=200) - - - def pretty_print_POST(req): - """ - At this point it is completely built and ready - to be fired; it is "prepared". - - However pay attention at the formatting used in - this function because it is programmed to be pretty - printed and may differ from the actual request. - """ - print('{}\n{}\r\n{}\r\n\r\n{}'.format( - '-----------START-----------', - req.method + ' ' + req.url, - '\r\n'.join('{}: {}'.format(k, v) for k, v in req.headers.items()), - req.body, - )) + return JsonResponse({}, safe=False, status=200) diff --git a/backend/setup.py b/backend/setup.py index 0c7cd6c..0962694 100644 --- a/backend/setup.py +++ b/backend/setup.py @@ -19,6 +19,7 @@ setup( 'whitenoise==5.2.0', 'oauth2==1.1.1', 'oauthlib==3.1.0', + 'py-jwt-validator==0.6.0', ], license='BSD License', # example license description='DESCRIPTION' diff --git a/frontend/src/app/component/login/login.component.ts b/frontend/src/app/component/login/login.component.ts index fad8316..17edcfd 100644 --- a/frontend/src/app/component/login/login.component.ts +++ b/frontend/src/app/component/login/login.component.ts @@ -64,8 +64,9 @@ export class LoginComponent implements OnInit { }; return this.http.get('http://localhost:8000/api/login', { - headers: new HttpHeaders(headerDict) + headers: new HttpHeaders(headerDict), + observe: 'response', }) - .subscribe(data => console.log(data)); + .subscribe(data => alert("Returned with code: "+data['status'])); } }