Skip to content

Commit

Permalink
fix(supabase): fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
StanGirard committed Dec 3, 2023
1 parent 882a10c commit a5ef5a0
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 37 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)



Expand Down
66 changes: 33 additions & 33 deletions backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,39 +52,39 @@
],
)

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)


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")
# 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)


# 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()
Expand Down

0 comments on commit a5ef5a0

Please sign in to comment.