Fixed authUser to user link #358
This commit is contained in:
parent
12fbc972d9
commit
cdfd151851
@ -494,8 +494,14 @@ class AuthService(AuthServiceABC):
|
||||
added_user = True
|
||||
|
||||
db_user = self._auth_users.get_auth_user_by_email(user_dto.email)
|
||||
if db_user.users.count() == 0:
|
||||
members.for_each(lambda x: self._auth_users.add_auth_user_user_rel(AuthUserUsersRelation(db_user, x)))
|
||||
|
||||
auth_user_relation_ids = self._auth_users.get_auth_user_relation_ids(db_user)
|
||||
|
||||
for user in db_user.users:
|
||||
if user.id in auth_user_relation_ids:
|
||||
continue
|
||||
|
||||
self._auth_users.add_auth_user_user_rel(AuthUserUsersRelation(db_user, user))
|
||||
|
||||
if db_user.confirmation_id is not None and not added_user:
|
||||
raise ServiceException(ServiceErrorCode.Forbidden, "E-Mail not verified")
|
||||
|
@ -14,6 +14,10 @@ class AuthUserRepositoryABC(ABC):
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def get_auth_user_relation_ids(self, auth_user: AuthUser) -> List[int]:
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def get_all_auth_users(self) -> List[AuthUser]:
|
||||
pass
|
||||
|
@ -50,13 +50,7 @@ class AuthUserRepositoryService(AuthUserRepositoryABC):
|
||||
auth_user_id=self._get_value_from_result(au_result[0]),
|
||||
)
|
||||
|
||||
self._logger.trace(
|
||||
__name__,
|
||||
f"Send SQL command: {auth_user.get_select_user_id_from_relations()}",
|
||||
)
|
||||
results = self._context.select(auth_user.get_select_user_id_from_relations())
|
||||
for result in results:
|
||||
user_id = self._get_value_from_result(result[0])
|
||||
for user_id in self.get_auth_user_relation_ids(auth_user):
|
||||
if user_id is None:
|
||||
continue
|
||||
|
||||
@ -65,6 +59,19 @@ class AuthUserRepositoryService(AuthUserRepositoryABC):
|
||||
|
||||
return auth_user
|
||||
|
||||
def get_auth_user_relation_ids(self, auth_user: AuthUser) -> List[int]:
|
||||
self._logger.trace(
|
||||
__name__,
|
||||
f"Send SQL command: {auth_user.get_select_user_id_from_relations()}",
|
||||
)
|
||||
relation_ids = List(int)
|
||||
results = self._context.select(auth_user.get_select_user_id_from_relations())
|
||||
for result in results:
|
||||
self._logger.trace(__name__, f"Got auth user relation with id {result[0]}")
|
||||
relation_ids.append(result[0])
|
||||
|
||||
return relation_ids
|
||||
|
||||
def get_all_auth_users(self) -> List[AuthUser]:
|
||||
users = List(AuthUser)
|
||||
self._logger.trace(__name__, f"Send SQL command: {AuthUser.get_select_all_string()}")
|
||||
|
Loading…
Reference in New Issue
Block a user