fix: sync separates account status from console login status
- Account status now comes from Volcengine User.Status field (active/disabled) - Console login status synced to volc_login_allowed separately - Fixes: closing Volcengine login no longer marks account as disabled after sync - Handles ghost LoginProfile (CreateDate=1970) correctly during sync Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
40655d63e0
commit
9cfd550485
@ -213,13 +213,26 @@ def iam_user_sync_view(request):
|
|||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Sync login status
|
# Sync account status from Volcengine user status (not login profile)
|
||||||
|
volc_status = u.get("Status", "active")
|
||||||
|
if volc_status == "active":
|
||||||
|
obj.status = IAMUser.Status.ACTIVE
|
||||||
|
elif volc_status == "disabled":
|
||||||
|
obj.status = IAMUser.Status.DISABLED
|
||||||
|
else:
|
||||||
|
obj.status = IAMUser.Status.UNKNOWN
|
||||||
|
|
||||||
|
# Sync volc login status separately
|
||||||
try:
|
try:
|
||||||
profile = svc.get_login_profile(username)
|
profile = svc.get_login_profile(username)
|
||||||
login_allowed = profile.get("Result", {}).get("LoginProfile", {}).get("LoginAllowed", True)
|
lp = profile.get("Result", {}).get("LoginProfile", {})
|
||||||
obj.status = IAMUser.Status.ACTIVE if login_allowed else IAMUser.Status.DISABLED
|
create_date = lp.get("CreateDate", "")
|
||||||
|
if create_date.startswith("1970") or create_date.startswith("0001"):
|
||||||
|
obj.volc_login_allowed = False
|
||||||
|
else:
|
||||||
|
obj.volc_login_allowed = lp.get("LoginAllowed", False)
|
||||||
except Exception:
|
except Exception:
|
||||||
obj.status = IAMUser.Status.UNKNOWN
|
obj.volc_login_allowed = False
|
||||||
|
|
||||||
obj.save()
|
obj.save()
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user