Musolyze / auth.py
Danialebrat's picture
adding codes and files
fe8a467
raw
history blame contribute delete
503 Bytes
import json
import os
def load_access_json(file_path: str) -> dict:
"""Load the JSON file containing the allowed emails."""
with open(file_path, 'r') as f:
return json.load(f)
def authenticator(email: str, token: str, auth_token: str, access_json_path: str) -> bool:
"""Check if the provided email and token are valid."""
emails_data = load_access_json(access_json_path)
email_list = emails_data["email"]
return (email.lower() in email_list) and (token == auth_token)