Api v1.15.0 (#1632)
* refactor(chalice): refactored logs fix(chalice): fixed edit account
This commit is contained in:
parent
6576d619e5
commit
8a370fc2ae
5 changed files with 23 additions and 43 deletions
|
|
@ -114,6 +114,10 @@ def reset_member(tenant_id, editor_id, user_id_to_update):
|
|||
|
||||
|
||||
def update(tenant_id, user_id, changes, output=True):
|
||||
print("---------")
|
||||
print(tenant_id)
|
||||
print(user_id)
|
||||
print(changes)
|
||||
AUTH_KEYS = ["password", "invitationToken", "invitedAt", "changePwdExpireAt", "changePwdToken"]
|
||||
if len(changes.keys()) == 0:
|
||||
return None
|
||||
|
|
@ -132,39 +136,20 @@ def update(tenant_id, user_id, changes, output=True):
|
|||
|
||||
with pg_client.PostgresClient() as cur:
|
||||
if len(sub_query_users) > 0:
|
||||
cur.execute(
|
||||
cur.mogrify(f"""\
|
||||
query = cur.mogrify(f"""\
|
||||
UPDATE public.users
|
||||
SET {" ,".join(sub_query_users)}
|
||||
FROM public.basic_authentication
|
||||
WHERE users.user_id = %(user_id)s
|
||||
AND users.user_id = basic_authentication.user_id
|
||||
RETURNING users.user_id,
|
||||
users.email,
|
||||
users.role,
|
||||
users.name,
|
||||
(CASE WHEN users.role = 'owner' THEN TRUE ELSE FALSE END) AS super_admin,
|
||||
(CASE WHEN users.role = 'admin' THEN TRUE ELSE FALSE END) AS admin,
|
||||
(CASE WHEN users.role = 'member' THEN TRUE ELSE FALSE END) AS member;""",
|
||||
{"user_id": user_id, **changes})
|
||||
)
|
||||
WHERE users.user_id = %(user_id)s;""",
|
||||
{"user_id": user_id, **changes})
|
||||
cur.execute(query)
|
||||
print(query)
|
||||
if len(sub_query_bauth) > 0:
|
||||
cur.execute(
|
||||
cur.mogrify(f"""\
|
||||
query = cur.mogrify(f"""\
|
||||
UPDATE public.basic_authentication
|
||||
SET {" ,".join(sub_query_bauth)}
|
||||
FROM public.users AS users
|
||||
WHERE basic_authentication.user_id = %(user_id)s
|
||||
AND users.user_id = basic_authentication.user_id
|
||||
RETURNING users.user_id,
|
||||
users.email,
|
||||
users.role,
|
||||
users.name,
|
||||
(CASE WHEN users.role = 'owner' THEN TRUE ELSE FALSE END) AS super_admin,
|
||||
(CASE WHEN users.role = 'admin' THEN TRUE ELSE FALSE END) AS admin,
|
||||
(CASE WHEN users.role = 'member' THEN TRUE ELSE FALSE END) AS member;""",
|
||||
{"user_id": user_id, **changes})
|
||||
)
|
||||
WHERE basic_authentication.user_id = %(user_id)s;""",
|
||||
{"user_id": user_id, **changes})
|
||||
cur.execute(query)
|
||||
if not output:
|
||||
return None
|
||||
return get(user_id=user_id, tenant_id=tenant_id)
|
||||
|
|
|
|||
|
|
@ -72,10 +72,11 @@ class SMTPClient:
|
|||
|
||||
VALID_SMTP = None
|
||||
SMTP_ERROR = None
|
||||
SMTP_NOTIFIED = False
|
||||
|
||||
|
||||
def has_smtp():
|
||||
global VALID_SMTP, SMTP_ERROR
|
||||
global VALID_SMTP, SMTP_ERROR, SMTP_NOTIFIED
|
||||
if SMTP_ERROR is not None:
|
||||
logging.error("!!! SMTP error found, disabling SMTP configuration:")
|
||||
logging.error(SMTP_ERROR)
|
||||
|
|
@ -86,7 +87,8 @@ def has_smtp():
|
|||
if config("EMAIL_HOST") is not None and len(config("EMAIL_HOST")) > 0:
|
||||
VALID_SMTP, SMTP_ERROR = check_connexion()
|
||||
return VALID_SMTP
|
||||
else:
|
||||
elif not SMTP_NOTIFIED:
|
||||
SMTP_NOTIFIED = True
|
||||
logging.info("no SMTP configuration found")
|
||||
return False
|
||||
|
||||
|
|
|
|||
|
|
@ -103,14 +103,13 @@ def get_account(context: schemas.CurrentContext = Depends(OR_context)):
|
|||
t = tenants.get_by_tenant_id(context.tenant_id)
|
||||
if t is not None:
|
||||
t["createdAt"] = TimeUTC.datetime_to_timestamp(t["createdAt"])
|
||||
t["tenantName"] = t.get("name")
|
||||
t["tenantName"] = t.pop("name")
|
||||
return {
|
||||
'data': {
|
||||
**r,
|
||||
**t,
|
||||
**license.get_status(context.tenant_id),
|
||||
"smtp": smtp.has_smtp(),
|
||||
# "iceServers": assist.get_ice_servers()
|
||||
"smtp": smtp.has_smtp()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -166,10 +166,8 @@ def update(tenant_id, user_id, changes, output=True):
|
|||
cur.mogrify(f"""\
|
||||
UPDATE public.users
|
||||
SET {" ,".join(sub_query_users)}
|
||||
FROM public.basic_authentication
|
||||
WHERE users.user_id = %(user_id)s
|
||||
AND users.tenant_id = %(tenant_id)s
|
||||
AND users.user_id = basic_authentication.user_id;""",
|
||||
AND users.tenant_id = %(tenant_id)s;""",
|
||||
{"tenant_id": tenant_id, "user_id": user_id, **changes})
|
||||
)
|
||||
if len(sub_query_bauth) > 0:
|
||||
|
|
@ -177,10 +175,7 @@ def update(tenant_id, user_id, changes, output=True):
|
|||
cur.mogrify(f"""\
|
||||
UPDATE public.basic_authentication
|
||||
SET {" ,".join(sub_query_bauth)}
|
||||
FROM public.users AS users
|
||||
WHERE basic_authentication.user_id = %(user_id)s
|
||||
AND users.tenant_id = %(tenant_id)s
|
||||
AND users.user_id = basic_authentication.user_id;""",
|
||||
WHERE basic_authentication.user_id = %(user_id)s;""",
|
||||
{"tenant_id": tenant_id, "user_id": user_id, **changes})
|
||||
)
|
||||
if not output:
|
||||
|
|
|
|||
|
|
@ -108,15 +108,14 @@ def get_account(context: schemas.CurrentContext = Depends(OR_context)):
|
|||
t = tenants.get_by_tenant_id(context.tenant_id)
|
||||
if t is not None:
|
||||
t["createdAt"] = TimeUTC.datetime_to_timestamp(t["createdAt"])
|
||||
t["tenantName"] = t.get("name")
|
||||
t["tenantName"] = t.pop("name")
|
||||
return {
|
||||
'data': {
|
||||
**r,
|
||||
**t,
|
||||
**license.get_status(context.tenant_id),
|
||||
"smtp": smtp.has_smtp(),
|
||||
"saml2": SAML2_helper.is_saml2_available(),
|
||||
# "iceServers": assist.get_ice_servers()
|
||||
"saml2": SAML2_helper.is_saml2_available()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue