feat(api): allow change password for double-auth

This commit is contained in:
Taha Yassine Kraiem 2021-12-03 12:02:50 +01:00
parent 63bc981dc8
commit 8a1c05697f
3 changed files with 5 additions and 4 deletions

View file

@ -11,7 +11,7 @@ def reset(data):
if "email" not in data:
return {"errors": ["email not found in body"]}
if not helper.has_smtp():
return {"errors": ["no SMTP configuration found"]}
return {"errors": ["no SMTP configuration found, you can ask your admin to reset your password"]}
a_users = users.get_by_email_only(data["email"])
if len(a_users) > 1:
print(f"multiple users found for [{data['email']}] please contact our support")

View file

@ -11,7 +11,7 @@ def reset(data):
if "email" not in data:
return {"errors": ["email not found in body"]}
if not helper.has_smtp():
return {"errors": ["no SMTP configuration found"]}
return {"errors": ["no SMTP configuration found, you can ask your admin to reset your password"]}
a_user = users.get_by_email_only(data["email"])
if a_user is not None:
# ---FOR SSO

View file

@ -261,7 +261,8 @@ def get(user_id, tenant_id):
origin,
role_id,
roles.name AS role_name,
roles.permissions
roles.permissions,
basic_authentication.password IS NOT NULL AS has_password
FROM public.users LEFT JOIN public.basic_authentication ON users.user_id=basic_authentication.user_id
LEFT JOIN public.roles USING (role_id)
WHERE
@ -446,7 +447,7 @@ def change_password(tenant_id, user_id, email, old_password, new_password):
item = get(tenant_id=tenant_id, user_id=user_id)
if item is None:
return {"errors": ["access denied"]}
if item["origin"] is not None:
if item["origin"] is not None and item["hasPassword"] is False:
return {"errors": ["cannot change your password because you are logged-in form an SSO service"]}
if old_password == new_password:
return {"errors": ["old and new password are the same"]}