mirror of
https://github.com/i701/sarlink-portal-api.git
synced 2025-04-19 17:36:53 +00:00
Refactor user verification to use PEOPLE_API_URL and added error handling for missing environment variable
All checks were successful
Build and Push Docker Images / Build and Push Docker Images (push) Successful in 5m3s
All checks were successful
Build and Push Docker Images / Build and Push Docker Images (push) Successful in 5m3s
This commit is contained in:
parent
88a2b8ead2
commit
7777545bec
@ -4,9 +4,9 @@ import requests
|
||||
from apibase.env import env, BASE_DIR
|
||||
import os
|
||||
|
||||
PERSON_API_URL = env.str("PERSON_VERIFY_BASE_URL", "")
|
||||
|
||||
env.read_env(os.path.join(BASE_DIR, ".env"))
|
||||
PEOPLE_API_URL = env.str("PEOPLE_API_URL", "")
|
||||
|
||||
|
||||
def verify_user_with_person_api_task(user_id: int):
|
||||
@ -17,7 +17,9 @@ def verify_user_with_person_api_task(user_id: int):
|
||||
|
||||
user = get_object_or_404(User, id=user_id)
|
||||
# Call the Person API to verify the user
|
||||
response = requests.get(f"{PERSON_API_URL}/api/person/{user.id_card}")
|
||||
if not PEOPLE_API_URL:
|
||||
raise ValueError("PEOPLE_API_URL is not set in the environment variables.")
|
||||
response = requests.get(f"{PEOPLE_API_URL}/api/person/{user.id_card}")
|
||||
if response.status_code == 200:
|
||||
data = response.json()
|
||||
api_nic = data.get("nic")
|
||||
|
Loading…
x
Reference in New Issue
Block a user