Skip to content

Added table for full admin access #165

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions business_objects/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,15 @@ def update_last_interaction(user_id: str) -> None:
user_item = get(user_id)
user_item.last_interaction = sql.func.now()
general.commit()


def check_email_in_full_admin(email: str) -> bool:
email = prevent_sql_injection(email, isinstance(email, str))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since emails are stored lower case we should also check lower case

Suggested change
email = prevent_sql_injection(email, isinstance(email, str))
email = email.lower()
email = prevent_sql_injection(email, isinstance(email, str))

query = f"""
SELECT EXISTS (
SELECT 1
FROM global.full_admin_access
WHERE email = '{email}'
)
"""
return general.execute_first(query)[0]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't actually return a boolean, should be converted (

result = general.execute_first(query)
if result and result[0]:
    return True
return False

1 change: 1 addition & 0 deletions enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ class Tablenames(Enum):
EVALUATION_GROUP = "evaluation_group"
EVALUATION_RUN = "evaluation_run"
PLAYGROUND_QUESTION = "playground_question"
FULL_ADMIN_ACCESS = "full_admin_access"

def snake_case_to_pascal_case(self):
# the type name (written in PascalCase) of a table is needed to create backrefs
Expand Down
8 changes: 8 additions & 0 deletions models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2062,3 +2062,11 @@ class PlaygroundQuestion(Base):
# )
# record_ids = Column(JSON)
# meta_info = Column(JSON)


class FullAdminAccess(Base):
__tablename__ = Tablenames.FULL_ADMIN_ACCESS.value
__table_args__ = {"schema": "global"}
id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
email = Column(String, unique=True)
meta_info = Column(JSON)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this for?