{"record":{"id":"a477bba50f276961","repo":"Mintplex-Labs/anything-llm","slug":"user-is-suspended-cannot-register-device","errorCode":null,"errorMessage":"User is suspended - cannot register device","messagePattern":"User is suspended - cannot register device","errorType":"http","errorClass":null,"httpStatus":400,"severity":"error","filePath":"server/endpoints/mobile/middleware/index.js","lineNumber":80,"sourceCode":"    if (!tempTokenData)\n      return response\n        .status(400)\n        .json({ error: \"Invalid or expired registration token\" });\n\n    // If in multi-user mode, we need to validate the user id\n    // associated exists, is not banned and then associate with locals so we can reuse it later.\n    // If not in multi-user mode then simply having a valid token is enough.\n    const multiUserMode = await SystemSettings.isMultiUserMode();\n    if (multiUserMode) {\n      if (!tempTokenData.userId)\n        return response\n          .status(400)\n          .json({ error: \"User id not found in registration token\" });\n      const user = await User.get({ id: Number(tempTokenData.userId) });\n      if (!user) return response.status(400).json({ error: \"User not found\" });\n      if (user.suspended)\n        return response\n          .status(400)\n          .json({ error: \"User is suspended - cannot register device\" });\n      response.locals.user = user;\n    }\n\n    next();\n  } catch (error) {\n    console.error(\"validRegistrationToken:error\", error);\n    response.status(500).json({\n      error: \"Invalid middleware response from validRegistrationToken\",\n    });\n  }\n}\n\nmodule.exports = {\n  validDeviceToken,\n  validRegistrationToken,\n};\n","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/server/endpoints/mobile/middleware/index.js#L62-L98","documentation":"Multi-user registration check: if the user tied to the temp token has suspended = true, validRegistrationToken returns 400 { error: 'User is suspended - cannot register device' } before attaching response.locals.user, so MobileDevice.create is never called for that account.","triggerScenarios":"A suspended user opens a connect-info/QR generated before suspension (or while suspension was being applied) and attempts to register a device.","commonSituations":"Suspension landing while the pairing flow was in progress; stale QR codes shared before the account was suspended.","solutions":["Admin unsuspends the account, then restart pairing with fresh connect-info","Or pair the device to an active account instead","Show 'account suspended — contact admin' in the UI and stop the flow; retrying the same token will not help"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await register(tempToken);\n} catch (e) {\n  if (e.status === 400 && e.body?.error?.includes('cannot register device')) {\n    return showFatal('Account suspended — pair with an active account or contact admin');\n  }\n  throw e;\n}","preventionTips":["Check account status before starting device pairing","Stop the pairing flow on suspension errors — retries are futile","Admins: unsuspend first, then issue fresh connect-info"],"tags":["mobile","registration","suspended","multi-user","account-state"],"backgroundTag":"user-account-suspended","analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-08-23T16:17:53.355Z"}