diff --git a/src/regps/app/fastapi_app.py b/src/regps/app/fastapi_app.py index 497cd22..5774bfa 100644 --- a/src/regps/app/fastapi_app.py +++ b/src/regps/app/fastapi_app.py @@ -53,9 +53,6 @@ async def login(response: Response, data: LoginRequest): try: logger.info(f"Login: sending login cred {str(data)[:50]}...") resp = api_controller.login(data.said, data.vlei) - lei = resp.get("lei") - aid = resp.get("aid") - reports_db.register_aid(aid, lei) return JSONResponse(status_code=202, content=resp) except VerifierServiceException as e: logger.error(f"Login: Exception: {e}") @@ -86,6 +83,9 @@ async def check_login_route( try: logger.info(f"CheckLogin: sending aid {aid}") resp = api_controller.check_login(aid) + lei = resp.get("lei") + aid = resp.get("aid") + reports_db.register_aid(aid, lei) return JSONResponse(status_code=200, content=resp) except VerifierServiceException as e: logger.error(f"CheckLogin: Exception: {e}") diff --git a/tests/unit/test_service.py b/tests/unit/test_service.py index f535adf..e53e16f 100644 --- a/tests/unit/test_service.py +++ b/tests/unit/test_service.py @@ -54,6 +54,7 @@ def test_ends(): result = client.get(f"/checklogin/{AID}", headers=headers) assert result.status_code == 200 + assert result.text == '{"aid":"EP4kdoVrDh4Mpzh2QbocUYIv4IjLZLDU367UO0b40f6x","said":"EElnd1DKvcDzzh7u7jBjsg2X9WgdQQuhgiu80i2VR-gk","lei":"875500ELOZEL05BVXV37","msg":"AID EP4kdoVrDh4Mpzh2QbocUYIv4IjLZLDU367UO0b40f6x w/ lei 875500ELOZEL05BVXV37 presented valid credential"}' result = client.get(f"/upload/{AID}/{DIG}", headers=headers) assert result.status_code == 401 # fail because this signature should not verify