From 8d4d61103abd046f281e487da40e7c02ffdd52ee Mon Sep 17 00:00:00 2001 From: Taha Yassine Kraiem Date: Fri, 10 Jun 2022 15:44:05 +0200 Subject: [PATCH] feat(api): fixed login response --- api/chalicelib/core/users.py | 2 +- ee/api/chalicelib/core/users.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/api/chalicelib/core/users.py b/api/chalicelib/core/users.py index 082e9aca9..8eb08bd35 100644 --- a/api/chalicelib/core/users.py +++ b/api/chalicelib/core/users.py @@ -586,7 +586,7 @@ def authenticate(email, password, for_change_password=False, for_plugin=False): {"user_id": r["id"]}) cur.execute(query) return { - "jwt": authorizers.generate_jwt(r['id'], r['tenantId'], + "jwt": authorizers.generate_jwt(r['userId'], r['tenantId'], TimeUTC.datetime_to_timestamp(cur.fetchone()["jwt_iat"]), aud=f"plugin:{helper.get_stage_name()}" if for_plugin else f"front:{helper.get_stage_name()}"), "email": email, diff --git a/ee/api/chalicelib/core/users.py b/ee/api/chalicelib/core/users.py index 6a51a1d80..49081b12a 100644 --- a/ee/api/chalicelib/core/users.py +++ b/ee/api/chalicelib/core/users.py @@ -666,7 +666,7 @@ def authenticate(email, password, for_change_password=False, for_plugin=False): if for_change_password: return True r = helper.dict_to_camel_case(r) - jwt_iat = change_jwt_iat(r['id']) + jwt_iat = change_jwt_iat(r['userId']) return { "jwt": authorizers.generate_jwt(r['id'], r['tenantId'], TimeUTC.datetime_to_timestamp(jwt_iat), @@ -681,7 +681,7 @@ def authenticate_sso(email, internal_id, exp=None): with pg_client.PostgresClient() as cur: query = cur.mogrify( f"""SELECT - users.user_id AS id, + users.user_id, users.tenant_id, users.role, users.name, @@ -699,7 +699,7 @@ def authenticate_sso(email, internal_id, exp=None): if r is not None: r = helper.dict_to_camel_case(r) - jwt_iat = TimeUTC.datetime_to_timestamp(change_jwt_iat(r['id'])) + jwt_iat = TimeUTC.datetime_to_timestamp(change_jwt_iat(r['userId'])) return authorizers.generate_jwt(r['id'], r['tenantId'], jwt_iat, aud=f"front:{helper.get_stage_name()}", exp=(exp + jwt_iat // 1000) if exp is not None else None)