Skip to content

Commit

Permalink
revert: account_type
Browse files Browse the repository at this point in the history
  • Loading branch information
MehmedGIT committed Apr 30, 2024
1 parent 0ccaa17 commit aaa2827
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/server/operandi_server/routers/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,20 +398,20 @@ async def submit_to_rabbitmq_queue(
encoded_workflow_message = dumps(workflow_processing_message)

# Send the message to a queue based on the user_id
if user_account_type == "HARVESTER":
if user_account_type == "harvester":
self.logger.info(f"Pushing to the RabbitMQ queue for the harvester: {RABBITMQ_QUEUE_HARVESTER}")
self.rmq_publisher.publish_to_queue(
queue_name=RABBITMQ_QUEUE_HARVESTER,
message=encoded_workflow_message
)
elif user_account_type == "ADMIN" or user_account_type == "USER":
elif user_account_type == "administrator" or user_account_type == "user":
self.logger.info(f"Pushing to the RabbitMQ queue for the users: {RABBITMQ_QUEUE_USERS}")
self.rmq_publisher.publish_to_queue(
queue_name=RABBITMQ_QUEUE_USERS,
message=encoded_workflow_message
)
else:
account_types = ["USER", "HARVESTER", "ADMIN"]
account_types = ["user", "harvester", "admin"]
message = f"The user account type is not valid: {user_account_type}. Must be one of: {account_types}"
self.logger.error(f"{message}")
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail=message)
Expand Down
4 changes: 2 additions & 2 deletions src/server/operandi_server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,14 @@ async def insert_default_accounts(self):
if default_admin_user and default_admin_pass:
await create_user_if_not_available(
username=default_admin_user, password=default_admin_pass,
account_type="ADMIN", approved_user=True
account_type="administrator", approved_user=True
)
self.log.info(f"Configured default server admin account")

self.log.info(f"Configuring default harvester account")
if default_harvester_user and default_harvester_pass:
await create_user_if_not_available(
username=default_harvester_user, password=default_harvester_pass,
account_type="HARVESTER", approved_user=True
account_type="harvester", approved_user=True
)
self.log.info(f"Configured default harvester account")
1 change: 1 addition & 0 deletions src/utils/operandi_utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
OPERANDI_VERSION = get_distribution("operandi_utils").version


# TODO: Still unused due to the need of changing all existing DB entries. Adapt it.
class AccountTypes(str, Enum):
ADMIN = "ADMIN"
HARVESTER = "HARVESTER"
Expand Down

0 comments on commit aaa2827

Please sign in to comment.