From aa48982c289c7cd1217f674cbe361122a964b17c Mon Sep 17 00:00:00 2001 From: Kraiem Taha Yassine Date: Tue, 7 Nov 2023 18:39:06 +0100 Subject: [PATCH] Api v1.15.0 (#1626) * refactor(chalice): changed signup response --- api/chalicelib/core/signup.py | 42 ++++---------------------------- ee/api/chalicelib/core/signup.py | 42 ++++---------------------------- 2 files changed, 10 insertions(+), 74 deletions(-) diff --git a/api/chalicelib/core/signup.py b/api/chalicelib/core/signup.py index 3d2d9381c..233a96578 100644 --- a/api/chalicelib/core/signup.py +++ b/api/chalicelib/core/signup.py @@ -3,7 +3,7 @@ import logging import schemas from chalicelib.core import users, telemetry, tenants -from chalicelib.utils import captcha +from chalicelib.utils import captcha, smtp from chalicelib.utils import helper from chalicelib.utils import pg_client from chalicelib.utils.TimeUTC import TimeUTC @@ -74,48 +74,16 @@ def create_tenant(data: schemas.UserSignupSchema): with pg_client.PostgresClient() as cur: cur.execute(cur.mogrify(query, params)) - data = cur.fetchone() - project_id = data["project_id"] - api_key = data["api_key"] + telemetry.new_client() - created_at = TimeUTC.now() r = users.authenticate(email, password) - r["banner"] = False - r["limits"] = { - "teamMember": {"limit": 99, "remaining": 98, "count": 1}, - "projects": {"limit": 99, "remaining": 98, "count": 1}, - "metadata": [{ - "projectId": project_id, - "name": project_name, - "limit": 10, - "remaining": 10, - "count": 0 - }] - } - c = { - "tenantId": 1, - "name": organization_name, - "apiKey": api_key, - "remainingTrial": 14, - "trialEnded": False, - "billingPeriodStartDate": created_at, - "hasActivePlan": True, - "projects": [ - { - "projectId": project_id, - "name": project_name, - "recorded": False, - "stackIntegrations": False, - "status": "red" - } - ] - } + r["smtp"] = smtp.has_smtp() + return { 'jwt': r.pop('jwt'), 'refreshToken': r.pop('refreshToken'), 'refreshTokenMaxAge': r.pop('refreshTokenMaxAge'), 'data': { - "user": r, - "client": c, + "user": r } } diff --git a/ee/api/chalicelib/core/signup.py b/ee/api/chalicelib/core/signup.py index 459aafa3c..949f0f2ec 100644 --- a/ee/api/chalicelib/core/signup.py +++ b/ee/api/chalicelib/core/signup.py @@ -5,7 +5,7 @@ from decouple import config import schemas from chalicelib.core import users, telemetry, tenants -from chalicelib.utils import captcha +from chalicelib.utils import captcha, smtp from chalicelib.utils import helper from chalicelib.utils import pg_client from chalicelib.utils.TimeUTC import TimeUTC @@ -83,48 +83,16 @@ def create_tenant(data: schemas.UserSignupSchema): with pg_client.PostgresClient() as cur: cur.execute(cur.mogrify(query, params)) - data = cur.fetchone() - project_id = data["project_id"] - api_key = data["api_key"] + telemetry.new_client(tenant_id=data["tenant_id"]) - created_at = TimeUTC.now() r = users.authenticate(email, password) - r["banner"] = False - r["limits"] = { - "teamMember": {"limit": 99, "remaining": 98, "count": 1}, - "projects": {"limit": 99, "remaining": 98, "count": 1}, - "metadata": [{ - "projectId": project_id, - "name": project_name, - "limit": 10, - "remaining": 10, - "count": 0 - }] - } - c = { - "tenantId": 1, - "name": organization_name, - "apiKey": api_key, - "remainingTrial": 14, - "trialEnded": False, - "billingPeriodStartDate": created_at, - "hasActivePlan": True, - "projects": [ - { - "projectId": project_id, - "name": project_name, - "recorded": False, - "stackIntegrations": False, - "status": "red" - } - ] - } + r["smtp"] = smtp.has_smtp() + return { 'jwt': r.pop('jwt'), 'refreshToken': r.pop('refreshToken'), 'refreshTokenMaxAge': r.pop('refreshTokenMaxAge'), 'data': { - "user": r, - "client": c, + "user": r } }