Skip to content
This repository has been archived by the owner on Sep 27, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into group-join
Browse files Browse the repository at this point in the history
  • Loading branch information
cstefc authored May 20, 2024
2 parents 321376f + 81d94c6 commit 8604e42
Show file tree
Hide file tree
Showing 18 changed files with 2,952 additions and 1,606 deletions.
12 changes: 10 additions & 2 deletions backend/controllers/authentication/authentication_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
from sqlmodel import Session

from db.models import User
from domain.logic.admin import create_admin
from domain.logic.role_enum import Role
from domain.logic.student import create_student
from domain.logic.user import get_user_with_email
from domain.logic.user import get_all_users, get_user_with_email, modify_user_roles

if TYPE_CHECKING:
from _elementtree import Element
Expand Down Expand Up @@ -36,7 +38,13 @@ def authenticate_user(session: Session, ticket: str) -> User | None:

user: User | None = get_user_with_email(session, user_dict["email"])
if user is None:
user = create_student(session, user_dict["name"], user_dict["email"]).user
num_users = len(get_all_users(session))
if num_users == 0:
admin = create_admin(session, user_dict["name"], user_dict["email"])
modify_user_roles(session, admin.id, [Role.ADMIN, Role.STUDENT])
user = admin.user
else:
user = create_student(session, user_dict["name"], user_dict["email"]).user
return user


Expand Down
4 changes: 2 additions & 2 deletions backend/errors/database_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ class ItemNotFoundError(ExceptionBase):
"""

def __init__(self, message: str) -> None:
self.ERROR_MESSAGE = message
self.STATUS_CODE = status.HTTP_404_NOT_FOUND
self.detail = message
self.status_code = status.HTTP_404_NOT_FOUND
super().__init__()


Expand Down
725 changes: 396 additions & 329 deletions backend/fill_database_mock.py

Large diffs are not rendered by default.

Loading

0 comments on commit 8604e42

Please sign in to comment.