From e97d82c6f0436272bdd67bd25f0f6ec4bc6af11f Mon Sep 17 00:00:00 2001
From: Mart van Santen <mart@greenhost.nl>
Date: Fri, 1 Apr 2022 16:52:57 +0800
Subject: [PATCH] Convert string object to dict

---
 areas/login/login.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/areas/login/login.py b/areas/login/login.py
index d2be28a1..2dc9f4a6 100644
--- a/areas/login/login.py
+++ b/areas/login/login.py
@@ -45,6 +45,7 @@ from helpers import (
     AppRole
 )
 
+import ast
 # This is a circular import and should be solved differently
 #from app import db
 from database import db
@@ -235,7 +236,12 @@ def consent():
     # Get information about this consent request:
     # False positive: pylint: disable=no-member
     try:
-        consent_client = consent_request.client.get('client_id')
+        consent_client = consent_request.client
+
+        # Some versions of Hydra module return a string object and need to be decoded
+        if isinstance(consent_client, str):
+            consent_client = ast.literal_eval(consent_client)
+
         app_id = consent_client.get('client_id')
         # False positive: pylint: disable=no-member
         kratos_id = consent_request.subject
-- 
GitLab