fix(user): allow password login and password change for Space accounts with local password set

Previously, Space accounts were unconditionally blocked from password login
and password change based on account_type. Now the check verifies whether
the user actually has a local password set, allowing Space users who have
set a local password to authenticate and change it normally.
This commit is contained in:
RockChinQ
2026-04-08 19:02:36 +08:00
parent e190029e1f
commit b894842736
+4 -5
View File
@@ -65,8 +65,8 @@ class UserService:
user_obj = result_list[0] user_obj = result_list[0]
# Check if this is a Space account # Check if this user has a local password set
if user_obj.account_type == 'space': if not user_obj.password:
raise ValueError('请使用 Space 账户登录') raise ValueError('请使用 Space 账户登录')
ph = argon2.PasswordHasher() ph = argon2.PasswordHasher()
@@ -108,9 +108,8 @@ class UserService:
if user_obj is None: if user_obj is None:
raise ValueError('User not found') raise ValueError('User not found')
# Space accounts cannot change password locally if not user_obj.password:
if user_obj.account_type == 'space': raise ValueError('No local password set, please set a password first')
raise ValueError('Space account cannot change password locally')
ph.verify(user_obj.password, current_password) ph.verify(user_obj.password, current_password)