feat(api): update internal id for existing account
This commit is contained in:
parent
09daaa2666
commit
e081fdc446
2 changed files with 14 additions and 0 deletions
|
|
@ -134,6 +134,7 @@ async def create_oauth_tenant(fullname: str, email: str):
|
|||
errors.append("Invalid email address.")
|
||||
else:
|
||||
if users.email_exists(email):
|
||||
users.update_user_internal_id(email, email)
|
||||
return users.authenticate_sso(email, email)
|
||||
if users.get_deleted_user_by_email(email) is not None:
|
||||
errors.append("Email address previously deleted.")
|
||||
|
|
|
|||
|
|
@ -1020,3 +1020,16 @@ def update_user_settings(user_id, settings):
|
|||
{"user_id": user_id, "settings": json.dumps(settings)})
|
||||
)
|
||||
return helper.dict_to_camel_case(cur.fetchone())
|
||||
|
||||
|
||||
def update_user_internal_id(email, internal_id):
|
||||
with pg_client.PostgresClient() as cur:
|
||||
cur.execute(
|
||||
cur.mogrify(
|
||||
f"""UPDATE public.users
|
||||
SET internal_id = %(internal_id)s
|
||||
WHERE email = %(email)s
|
||||
AND deleted_at IS NULL;""",
|
||||
{"email": email, "internal_id": internal_id})
|
||||
)
|
||||
return helper.dict_to_camel_case(cur.fetchone())
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue