send Requester to get_user_role

pull/178/head
dlamarcheteamnet 7 months ago
parent 98a56cf408
commit 8104b494a8
  1. 6
      synapse/handlers/watcha_administration.py
  2. 2
      synapse/handlers/watcha_nextcloud.py

@ -2,6 +2,7 @@ import logging
from synapse.api.errors import SynapseError
from synapse.types import UserID
from synapse.types import Requester
from synapse.util.watcha import build_log_message
logger = logging.getLogger(__name__)
@ -58,14 +59,15 @@ class AdministrationHandler:
return target_role
async def get_user_role(self, user_id):
async def get_user_role(self, requester: Requester):
"""Retrieve user role [administrator|collaborator|partner]
Returns:
The user role.
"""
user_id = requester.user.to_string()
is_partner = await self.auth_handler.is_partner(user_id)
is_admin = await self.auth.is_server_admin(UserID.from_string(user_id))
is_admin = await self.auth.is_server_admin(requester)
if is_partner and is_admin:
raise SynapseError(

@ -45,7 +45,7 @@ class NextcloudHandler:
self, requester: Requester, room_id: str, user_id: str, membership: str
):
if (
await self.administration_handler.get_user_role(user_id) == "partner"
await self.administration_handler.get_user_role(requester) == "partner"
and not self.config.watcha.external_authentication_for_partners
):
return

Loading…
Cancel
Save