fix: detect ghost LoginProfile from Volcengine (CreateDate=1970)
Users created without console password have a phantom LoginProfile that GetLoginProfile returns but UpdateLoginProfile/DeleteLoginProfile reject. Now checking CreateDate to detect this. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
92172c6ec8
commit
40655d63e0
@ -198,9 +198,14 @@ class IAMService:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def _has_login_profile(self, username: str) -> bool:
|
def _has_login_profile(self, username: str) -> bool:
|
||||||
"""检查用户是否有 LoginProfile"""
|
"""检查用户是否有真实的 LoginProfile(火山可能返回空壳)"""
|
||||||
try:
|
try:
|
||||||
self.get_login_profile(username)
|
resp = self.get_login_profile(username)
|
||||||
|
profile = resp.get("Result", {}).get("LoginProfile", {})
|
||||||
|
# Empty shell has CreateDate=19700101 and Password=""
|
||||||
|
create_date = profile.get("CreateDate", "")
|
||||||
|
if create_date.startswith("1970") or create_date.startswith("0001"):
|
||||||
|
return False
|
||||||
return True
|
return True
|
||||||
except VolcengineAPIError as e:
|
except VolcengineAPIError as e:
|
||||||
if "LoginProfileNotExist" in str(e) or "RecordNotFound" in str(e):
|
if "LoginProfileNotExist" in str(e) or "RecordNotFound" in str(e):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user