Spaces:
Sleeping
Sleeping
Download Backend/confirm_users.py from smit9604/ExamCraftAI: direct link, hf CLI and curl.
- Browser
- Download file 1.14 kB
-
https://huggingface.co/spaces/smit9604/ExamCraftAI/resolve/main/Backend/confirm_users.py
- Command line
-
hf download hf://spaces/smit9604/ExamCraftAI/Backend/confirm_users.py
-
curl -L -o confirm_users.py https://huggingface.co/spaces/smit9604/ExamCraftAI/resolve/main/Backend/confirm_users.py
1.14 kB
| import os | |
| from supabase import create_client, Client | |
| from dotenv import load_dotenv | |
| load_dotenv(dotenv_path='E:/Backup/ExamCraft/Backend/.env.local') | |
| supabase_url: str = os.environ.get("SUPABASE_URL") | |
| supabase_key: str = os.environ.get("SUPABASE_SERVICE_ROLE_KEY") | |
| supabase: Client = create_client(supabase_url, supabase_key) | |
| def confirm_all_users(): | |
| try: | |
| # Get all users (paginated, but gets first page) | |
| users_response = supabase.auth.admin.list_users() | |
| users = users_response.users if hasattr(users_response, 'users') else users_response | |
| for user in users: | |
| try: | |
| # Update user's email_confirmed_at | |
| response = supabase.auth.admin.update_user_by_id( | |
| user.id, | |
| {"email_confirm": True} | |
| ) | |
| print(f"Confirmed user: {user.email}") | |
| except Exception as inner_e: | |
| print(f"Refused or unsupported for {user.email}: {inner_e}") | |
| except Exception as e: | |
| print(f"Error fetching users: {e}") | |
| if __name__ == "__main__": | |
| confirm_all_users() | |