Skip to content

Commit

Permalink
fix: fixing server issue for empty user (#28)
Browse files Browse the repository at this point in the history
* fix: fixing basemodel export error

* fix: fixing deploy condition in actions
  • Loading branch information
brayn003 committed Mar 31, 2024
1 parent 1c73ec3 commit 61ea494
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ jobs:
client: ${{ steps.release.outputs.client--release_created }}
server: ${{ steps.release.outputs.server--release_created }}
tick-workers: ${{ steps.release.outputs.tick-workers--release_created }}
root: ${{ steps.release.outputs.release_created }}
steps:
- uses: google-github-actions/release-please-action@v4
id: release
Expand All @@ -83,6 +84,7 @@ jobs:
needs: [push-server, push-client, push-tick-workers]
if: |
always() &&
needs.release-please.outputs.root &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled')
uses: brayn003/stonk.ninja/.github/workflows/deploy.yaml@main
Expand Down
14 changes: 4 additions & 10 deletions server/app/services/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ def __init__(self):
if not MONGODB_URI:
raise MissingEnvException("MONGODB_URI not found in environment variables")
if not MONGODB_DB_NAME:
raise MissingEnvException(
"MONGODB_DB_NAME not found in environment variables"
)
raise MissingEnvException("MONGODB_DB_NAME not found in environment variables")

client = pymongo.MongoClient(MONGODB_URI, uuidRepresentation="standard")
self._db: Database = client[MONGODB_DB_NAME]
Expand Down Expand Up @@ -49,21 +47,17 @@ def setup_db(self):
user_count = self._db["users"].estimated_document_count()
if user_count == 0:
if not ADMIN_EMAIL:
raise MissingEnvException(
"ADMIN_EMAIL not found in environment variables"
)
raise MissingEnvException("ADMIN_EMAIL not found in environment variables")
if not ADMIN_PASSWORD:
raise MissingEnvException(
"ADMIN_EMAIL not found in environment variables"
)
raise MissingEnvException("ADMIN_PASSWORD not found in environment variables")
# not the most secure solution as env will be avaialbe after setup but it is quick
user = User(
full_name="Admin",
email=ADMIN_EMAIL,
password=hash_password(ADMIN_PASSWORD),
is_admin=True,
)
self._db["users"].insert_one(user.model_dump())
self._db["users"].insert_one(user.model_dump(include={"password"}))

# binding collections
self.sessions = self._db["sessions"]
Expand Down

0 comments on commit 61ea494

Please sign in to comment.