feat(server): register flow flags accounts from test-seed invites
When a user registers with an invite_code whose marks_as_test=TRUE, their users_v2.is_test_account is set to TRUE. Normal invite codes and invite-less signups are unaffected. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -245,11 +245,23 @@ async def register(
|
|||||||
)
|
)
|
||||||
|
|
||||||
# --- Invite code validation ---
|
# --- Invite code validation ---
|
||||||
|
is_test_account = False
|
||||||
if has_invite:
|
if has_invite:
|
||||||
if not _admin_service:
|
if not _admin_service:
|
||||||
raise HTTPException(status_code=503, detail="Admin service not initialized")
|
raise HTTPException(status_code=503, detail="Admin service not initialized")
|
||||||
if not await _admin_service.validate_invite_code(request_body.invite_code):
|
if not await _admin_service.validate_invite_code(request_body.invite_code):
|
||||||
raise HTTPException(status_code=400, detail="Invalid or expired invite code")
|
raise HTTPException(status_code=400, detail="Invalid or expired invite code")
|
||||||
|
# Check if this invite flags new accounts as test accounts
|
||||||
|
invite_details = await _admin_service.get_invite_code_details(request_body.invite_code)
|
||||||
|
if invite_details and invite_details.get("marks_as_test"):
|
||||||
|
is_test_account = True
|
||||||
|
logger.info(
|
||||||
|
"test_seed_account_registering",
|
||||||
|
extra={
|
||||||
|
"username": request_body.username,
|
||||||
|
"invite_code": request_body.invite_code,
|
||||||
|
},
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
# No invite code — check if open signups are allowed
|
# No invite code — check if open signups are allowed
|
||||||
if config.INVITE_ONLY and config.DAILY_OPEN_SIGNUPS == 0:
|
if config.INVITE_ONLY and config.DAILY_OPEN_SIGNUPS == 0:
|
||||||
@@ -277,6 +289,7 @@ async def register(
|
|||||||
username=request_body.username,
|
username=request_body.username,
|
||||||
password=request_body.password,
|
password=request_body.password,
|
||||||
email=request_body.email,
|
email=request_body.email,
|
||||||
|
is_test_account=is_test_account,
|
||||||
)
|
)
|
||||||
|
|
||||||
if not result.success:
|
if not result.success:
|
||||||
|
|||||||
@@ -101,6 +101,7 @@ class AuthService:
|
|||||||
password: str,
|
password: str,
|
||||||
email: Optional[str] = None,
|
email: Optional[str] = None,
|
||||||
guest_id: Optional[str] = None,
|
guest_id: Optional[str] = None,
|
||||||
|
is_test_account: bool = False,
|
||||||
) -> RegistrationResult:
|
) -> RegistrationResult:
|
||||||
"""
|
"""
|
||||||
Register a new user account.
|
Register a new user account.
|
||||||
@@ -110,6 +111,7 @@ class AuthService:
|
|||||||
password: Plain text password.
|
password: Plain text password.
|
||||||
email: Optional email address.
|
email: Optional email address.
|
||||||
guest_id: Guest session ID if converting.
|
guest_id: Guest session ID if converting.
|
||||||
|
is_test_account: Mark this user as a soak-harness test account.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
RegistrationResult with user or error.
|
RegistrationResult with user or error.
|
||||||
@@ -151,6 +153,7 @@ class AuthService:
|
|||||||
guest_id=guest_id,
|
guest_id=guest_id,
|
||||||
verification_token=verification_token,
|
verification_token=verification_token,
|
||||||
verification_expires=verification_expires,
|
verification_expires=verification_expires,
|
||||||
|
is_test_account=is_test_account,
|
||||||
)
|
)
|
||||||
|
|
||||||
if not user:
|
if not user:
|
||||||
|
|||||||
Reference in New Issue
Block a user