{"record":{"id":"ab72794d935b266c","repo":"langgenius/dify","slug":"already-activate","errorCode":"already_activate","errorMessage":"Auth Token is invalid or account already activated, please check again.","messagePattern":"Auth Token is invalid or account already activated, please check again\\.","errorType":"error_code","errorClass":"AlreadyActivateError","httpStatus":403,"severity":"error","filePath":"api/controllers/console/auth/activate.py","lineNumber":157,"sourceCode":"        \"Account activated successfully\",\n        console_ns.models[ActivationResponse.__name__],\n    )\n    @console_ns.response(400, \"Already activated or invalid token\")\n    @model_validate(ActivatePayload)\n    def post(self, req_data: ActivatePayload):\n        \"\"\"Accept an invitation without letting an existing session act for another account.\n\n        Token-only activation remains available for legacy clients. When the request already\n        carries a console session, that session must belong to the account encoded in the\n        invitation before the token is consumed or tenant membership is changed.\n        \"\"\"\n\n        normalized_request_email = req_data.email.lower() if req_data.email else None\n        invitation = RegisterService.get_invitation_with_case_fallback(\n            req_data.workspace_id, req_data.email, req_data.token, session=db.session()\n        )\n        if invitation is None:\n            raise AlreadyActivateError()\n\n        account = invitation[\"account\"]\n        if extract_access_token(request):\n            current_account, _ = current_account_with_tenant()\n            if current_account.id != account.id:\n                raise InvitationAccountMismatchError()\n\n        if dify_config.DEPLOYMENT_EDITION == DeploymentEdition.CLOUD and BillingService.is_email_in_freeze(\n            account.email\n        ):\n            raise AccountInFreezeError()\n\n        tenant = invitation[\"tenant\"]\n        raw_role = invitation[\"data\"].get(\"role\")\n        try:\n            role = TenantAccountRole(raw_role) if raw_role else TenantAccountRole.NORMAL\n        except ValueError:\n            role = TenantAccountRole.NORMAL","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/api/controllers/console/auth/activate.py#L139-L175","documentation":"Raised as AlreadyActivateError (code 'already_activate', HTTP 400) by POST /activate when RegisterService.get_invitation_with_case_fallback returns None — the (workspace_id, email, token) triple does not match a pending invitation. Common when the token was already consumed, expired, or never existed.","triggerScenarios":"POST /console/api/activate with a token that has already been used, has expired, was revoked, or doesn't match the workspace_id/email pair. Also when email case does not match any stored invitation.","commonSituations":"Clicking an activation link twice (second click finds the token revoked); expired invitation; user changed email case; invitation was resent and the old token was invalidated; stale link from an old email.","solutions":["Request a fresh invitation/activation email so a new token is issued.","If already activated, simply sign in instead of re-using the activation link.","Ensure the email submitted matches the invited email exactly (the service does a case-insensitive fallback, but typos in the local part still fail).","Confirm workspace_id in the payload matches the inviting workspace."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await post('/activate', { workspace_id, email, token });\n} catch (e) {\n  if (e.code === 'already_activate') {\n    // prompt: 'try signing in, or request a new invitation'\n  } else { throw e; }\n}","preventionTips":["Treat activation links as single-use; don't click twice.","If the link is old, request a fresh invitation rather than retrying.","Sign in directly if the account is already active."],"tags":["api","auth","invitation","activation","token"],"backgroundTag":null,"analyzedSha":"ef8544b173fd6cd7a8e71df2cab576e52bebbfbc","analyzedAt":"2026-08-12T05:15:17.394Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}