From e93c2578faf889d7cf3ab7d2031062558c17871c Mon Sep 17 00:00:00 2001 From: Arie Peterson <arie@greenhost.nl> Date: Fri, 21 Jun 2024 11:32:05 +0200 Subject: [PATCH] Use kratos api for looking up user by email address --- backend/helpers/kratos_user.py | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/backend/helpers/kratos_user.py b/backend/helpers/kratos_user.py index 34f0527a..242d8790 100644 --- a/backend/helpers/kratos_user.py +++ b/backend/helpers/kratos_user.py @@ -150,23 +150,12 @@ class KratosUser(): kratos_id = None - # Get out user ID by iterating over all available IDs - page = 0 - while page >= 0: - if page == 0: - data = api.list_identities(per_page=1000) - else: - data = api.list_identities(per_page=1000, page=page) - for kratos_obj in data: - # Unique identifier we use - if kratos_obj.traits['email'] == email: - kratos_id = str(kratos_obj.id) - return KratosUser(api, kratos_id) - if len(data) == 0: - page = -1 - else: - page = page + 1 - + data = api.list_identities(credentials_identifier=email) + for kratos_obj in data: + if kratos_obj.traits['email'].lower() == email.lower(): + kratos_id = str(kratos_obj.id) + return KratosUser(api, kratos_id) + # No user found with matching email address. return None @staticmethod -- GitLab