From 3bca89035af4d0d8af0ccd6de32243ec7ee6baf5 Mon Sep 17 00:00:00 2001
From: Arie Peterson <arie@greenhost.nl>
Date: Tue, 14 Feb 2023 17:16:14 +0100
Subject: [PATCH] Fix kratos API location for recovery flow

---
 backend/app.py                      | 1 -
 backend/areas/users/user_service.py | 7 ++++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/backend/app.py b/backend/app.py
index 067d4e14..896f1035 100644
--- a/backend/app.py
+++ b/backend/app.py
@@ -120,7 +120,6 @@ jwt = JWTManager(app)
 def expired_token_callback(*args):
     return jsonify({"errorMessage": "Unauthorized"}), 401
 
-
 @app.route("/")
 def index():
     return "Stackspin API v1.0"
diff --git a/backend/areas/users/user_service.py b/backend/areas/users/user_service.py
index a5869261..0e982eb7 100644
--- a/backend/areas/users/user_service.py
+++ b/backend/areas/users/user_service.py
@@ -1,7 +1,7 @@
 import ory_kratos_client
 from ory_kratos_client.model.update_recovery_flow_body \
     import UpdateRecoveryFlowBody
-from ory_kratos_client.api import identity_api
+from ory_kratos_client.api import frontend_api, identity_api
 from config import KRATOS_ADMIN_URL
 
 from database import db
@@ -16,6 +16,7 @@ from helpers.error_handler import KratosError
 kratos_admin_api_configuration = \
     ory_kratos_client.Configuration(host=KRATOS_ADMIN_URL, discard_unknown_keys=True)
 kratos_client = ory_kratos_client.ApiClient(kratos_admin_api_configuration)
+kratos_frontend_api = frontend_api.FrontendApi(kratos_client)
 kratos_identity_api = identity_api.IdentityApi(kratos_client)
 
 class UserService:
@@ -87,12 +88,12 @@ class UserService:
         :param email: Email to send recovery link to
         :type email: str
         """
-        api_response = kratos_identity_api.create_native_recovery_flow()
+        api_response = kratos_frontend_api.create_native_recovery_flow()
         flow = api_response['id']
         # Submit the recovery flow to send an email to the new user.
         update_recovery_flow_body = \
             UpdateRecoveryFlowBody(method="link", email=email)
-        api_response = kratos_identity_api.submit_self_service_recovery_flow(flow,
+        api_response = kratos_frontend_api.update_recovery_flow(flow,
                 update_recovery_flow_body=update_recovery_flow_body)
 
     @staticmethod
-- 
GitLab