fix(supabase): fixed

This commit is contained in:
Stan Girard 2023-12-03 01:35:01 +01:00
parent 882a10c459
commit a5ef5a0454
2 changed files with 34 additions and 34 deletions

View File

@ -87,13 +87,13 @@ You can find the installation video [here](https://www.youtube.com/watch?v=cXBa6
- **Step 5**: Login to the app
Connect to the supabase database at [http://localhost:8000/project/default/auth/users](http://localhost:8000/project/default/auth/users) with the following credentials: admin/admin in order to create new users. Auto-confirm the email.
You can now sign in to the app with your new user. You can access the app at [http://localhost:3000/login](http://localhost:3000/login).
Email: `admin@quivr.app`
Password: `admin`
You can also connect to the supabase database at [http://localhost:8000](http://localhost:8000) with the following credentials: admin/admin in order to create new users.
You can access Quivr backend API at [http://localhost:5050/](http://localhost:5050/)
You can access Quivr backend API at [http://localhost:5050/docs](http://localhost:5050/docs)

View File

@ -52,39 +52,39 @@ if sentry_dsn:
],
)
if CREATE_FIRST_USER := os.getenv("CREATE_FIRST_USER", "False").lower() == "true":
try:
from supabase import create_client
# if CREATE_FIRST_USER := os.getenv("CREATE_FIRST_USER", "False").lower() == "true":
# try:
# from supabase import create_client
supabase_client_auth = create_client(
os.getenv("SUPABASE_URL"), os.getenv("SUPABASE_SERVICE_KEY")
)
res = supabase_client_auth.from_('users').select('*').eq('email', "admin@quivr.app").execute()
if len(res.data) == 0:
supabase_client_auth.auth.admin.create_user({"email": "admin@quivr.app","email_confirm": True, "password": "admin"})
logger.info("👨‍💻 Created first user")
else:
logger.info("👨‍💻 First user already exists")
except Exception as e:
logger.error("👨‍💻 Error while creating first user")
logger.error(e)
# supabase_client_auth = create_client(
# os.getenv("SUPABASE_URL"), os.getenv("SUPABASE_SERVICE_KEY")
# )
# res = supabase_client_auth.from_('users').select('*').eq('email', "admin@quivr.app").execute()
# if len(res.data) == 0:
# supabase_client_auth.auth.admin.create_user({"email": "admin@quivr.app","email_confirm": True, "password": "admin"})
# logger.info("👨‍💻 Created first user")
# else:
# logger.info("👨‍💻 First user already exists")
# except Exception as e:
# logger.error("👨‍💻 Error while creating first user")
# logger.error(e)
telemetry_disabled = os.getenv("TELEMETRY_DISABLED", "False").lower() == "true"
if not telemetry_disabled:
try:
logger.info("👨‍💻 You can disable TELEMETRY by addind TELEMETRY_DISABLED=True to your env variables")
logger.info("Telemetry is used to measure the usage of the app. No personal data is collected.")
import os
from supabase import create_client
import uuid
supabase_url = os.environ.get("SUPABASE_URL", "NOT_SET")
supabase_client_telemetry = create_client("https://phcwncasycjransxnmbf.supabase.co","eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InBoY3duY2FzeWNqcmFuc3hubWJmIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MDE0NDM5NDEsImV4cCI6MjAxNzAxOTk0MX0.0MDz2ETHdQve9yVy_YI79iGsrlpLXX1ObrjmnzyVKSo")
## insert in the usage table id as uuid of supabase_url
uuid_from_string = uuid.uuid5(uuid.NAMESPACE_DNS, supabase_url)
supabase_client_telemetry.table("usage").insert({"id": str(uuid_from_string)}).execute()
except Exception as e:
logger.error("Error while sending telemetry")
# telemetry_disabled = os.getenv("TELEMETRY_DISABLED", "False").lower() == "true"
# if not telemetry_disabled:
# try:
# logger.info("👨‍💻 You can disable TELEMETRY by addind TELEMETRY_DISABLED=True to your env variables")
# logger.info("Telemetry is used to measure the usage of the app. No personal data is collected.")
# import os
# from supabase import create_client
# import uuid
# supabase_url = os.environ.get("SUPABASE_URL", "NOT_SET")
# supabase_client_telemetry = create_client("https://phcwncasycjransxnmbf.supabase.co","eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InBoY3duY2FzeWNqcmFuc3hubWJmIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MDE0NDM5NDEsImV4cCI6MjAxNzAxOTk0MX0.0MDz2ETHdQve9yVy_YI79iGsrlpLXX1ObrjmnzyVKSo")
# ## insert in the usage table id as uuid of supabase_url
# uuid_from_string = uuid.uuid5(uuid.NAMESPACE_DNS, supabase_url)
# supabase_client_telemetry.table("usage").insert({"id": str(uuid_from_string)}).execute()
# except Exception as e:
# logger.error("Error while sending telemetry")
app = FastAPI()