From cc7fc5ab91a9a1a56d5ba8092c8e47420bfe47b8 Mon Sep 17 00:00:00 2001 From: Maarten de Waard Date: Thu, 21 Jul 2022 16:53:08 +0200 Subject: [PATCH] replace tmp variable name, doc improvements --- areas/users/user_service.py | 13 ++++++++----- cliapp/cliapp/cli.py | 12 ++++++++---- web/login/login.py | 12 ++++++++---- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/areas/users/user_service.py b/areas/users/user_service.py index bd59f27..3b7fa68 100644 --- a/areas/users/user_service.py +++ b/areas/users/user_service.py @@ -9,8 +9,10 @@ from areas.apps.models import App, AppRole from areas.roles.role_service import RoleService from helpers import KratosApi -tmp = ory_kratos_client.Configuration(host=KRATOS_ADMIN_URL, discard_unknown_keys=True) -KRATOS_ADMIN = kratos_api.V0alpha2Api(ory_kratos_client.ApiClient(tmp)) +kratos_admin_api_configuration = \ + ory_kratos_client.Configuration(host=KRATOS_ADMIN_URL, discard_unknown_keys=True) +KRATOS_ADMIN = \ + kratos_api.V0alpha2Api(ory_kratos_client.ApiClient(kratos_admin_api_configuration)) class UserService: @staticmethod @@ -51,18 +53,19 @@ class UserService: db.session.add(app_role) db.session.commit() - UserService.__start_user_recovery_flow(data["email"]) + UserService.__start_recovery_flow(data["email"]) return UserService.get_user(res["id"]) @staticmethod - def __start_user_recovery_flow(email): + def __start_recovery_flow(email): """ Start a Kratos recovery flow for the user's email address. This sends out an email to the user that explains to them how they can - set their password. + set their password. Make sure the user exists inside Kratos before you + use this function. :param email: Email to send recovery link to :type email: str diff --git a/cliapp/cliapp/cli.py b/cliapp/cliapp/cli.py index 06e6fb0..6735cb2 100644 --- a/cliapp/cliapp/cli.py +++ b/cliapp/cliapp/cli.py @@ -27,11 +27,15 @@ HYDRA = hydra_client.HydraAdmin(HYDRA_ADMIN_URL) # Kratos has an admin and public end-point. We create an API for them # both. The kratos implementation has bugs, which forces us to set # the discard_unknown_keys to True. -tmp = ory_kratos_client.Configuration(host=KRATOS_ADMIN_URL, discard_unknown_keys=True) -KRATOS_ADMIN = kratos_api.V0alpha2Api(ory_kratos_client.ApiClient(tmp)) +kratos_admin_api_configuration = \ + ory_kratos_client.Configuration(host=KRATOS_ADMIN_URL, discard_unknown_keys=True) +KRATOS_ADMIN = \ + kratos_api.V0alpha2Api(ory_kratos_client.ApiClient(kratos_admin_api_configuration)) -tmp = ory_kratos_client.Configuration(host=KRATOS_PUBLIC_URL, discard_unknown_keys=True) -KRATOS_PUBLIC = kratos_api.V0alpha2Api(ory_kratos_client.ApiClient(tmp)) +kratos_public_api_configuration = \ + ory_kratos_client.Configuration(host=KRATOS_PUBLIC_URL, discard_unknown_keys=True) +KRATOS_PUBLIC = \ + kratos_api.V0alpha2Api(ory_kratos_client.ApiClient(kratos_public_api_configuration)) ############################################################################## # CLI INTERFACE # diff --git a/web/login/login.py b/web/login/login.py index 00cf3af..591acc2 100644 --- a/web/login/login.py +++ b/web/login/login.py @@ -31,11 +31,15 @@ HYDRA = hydra_client.HydraAdmin(HYDRA_ADMIN_URL) # Kratos has an admin and public end-point. We create an API for them # both. The kratos implementation has bugs, which forces us to set # the discard_unknown_keys to True. -tmp = ory_kratos_client.Configuration(host=KRATOS_ADMIN_URL, discard_unknown_keys=True) -KRATOS_ADMIN = kratos_api.V0alpha2Api(ory_kratos_client.ApiClient(tmp)) +kratos_admin_api_configuration = \ + ory_kratos_client.Configuration(host=KRATOS_ADMIN_URL, discard_unknown_keys=True) +KRATOS_ADMIN = \ + kratos_api.V0alpha2Api(ory_kratos_client.ApiClient(kratos_admin_api_configuration)) -tmp = ory_kratos_client.Configuration(host=KRATOS_PUBLIC_URL, discard_unknown_keys=True) -KRATOS_PUBLIC = kratos_api.V0alpha2Api(ory_kratos_client.ApiClient(tmp)) +kratos_public_api_configuration = \ + ory_kratos_client.Configuration(host=KRATOS_PUBLIC_URL, discard_unknown_keys=True) +KRATOS_PUBLIC = \ + kratos_api.V0alpha2Api(ory_kratos_client.ApiClient(kratos_public_api_configuration)) ADMIN_ROLE_ID = 1 NO_ACCESS_ROLE_ID = 3