{"record":{"id":"fa5a06da6634193d","repo":"louislam/dockge","slug":"you-are-not-logged-in","errorCode":null,"errorMessage":"You are not logged in.","messagePattern":"You are not logged in\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"backend/util-server.ts","lineNumber":44,"sourceCode":"    sslKey? : string;\n    sslCert? : string;\n    sslKeyPassphrase? : string;\n    port? : number;\n    hostname? : string;\n    dataDir? : string;\n    stacksDir? : string;\n    enableConsole? : boolean;\n}\n\n// Some config values are required\nexport interface Config extends Arguments {\n    dataDir : string;\n    stacksDir : string;\n}\n\nexport function checkLogin(socket : DockgeSocket) {\n    if (!socket.userID) {\n        throw new Error(\"You are not logged in.\");\n    }\n}\n\nexport class ValidationError extends Error {\n    constructor(message : string) {\n        super(message);\n    }\n}\n\nexport function callbackError(error : unknown, callback : unknown) {\n    if (typeof(callback) !== \"function\") {\n        log.error(\"console\", \"Callback is not a function\");\n        return;\n    }\n\n    if (error instanceof Error) {\n        callback({\n            ok: false,","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/louislam/dockge/blob/f809ae192b571944ad773e9866d3e67064ae8043/backend/util-server.ts#L26-L62","documentation":"checkLogin() in backend/util-server.ts guards every authenticated socket handler: if the socket has no userID (login did not happen or the session was lost), it throws 'You are not logged in.'. Dockge handlers call it first so unauthenticated clients can never touch stacks, files, or user data. It is called by handlers such as create/create2.","triggerScenarios":"Emitting a socket event that calls checkLogin (e.g. createStack, create2) from a socket that never completed the login handshake, whose token was rejected, or whose session was cleared (server restart, token expiry).","commonSituations":"Frontend kept open across a Dockge server restart, so the old socket lacks a userID; scripts/automation hitting the socket API without logging in; expired or revoked JWT after password change.","solutions":["Log in again from the Dockge UI to establish a new authenticated socket session","Reload the page so the frontend reconnects and re-authenticates the socket","In custom clients, perform the login event first and only then call protected actions","Check server logs for token/auth errors if login appears to succeed but the error persists"],"exampleFix":"// before (custom client calls protected handler directly)\nsocket.emit(\"createStack\", name, ...);\n// after\nsocket.emit(\"login\", username, password, (res) => {\n  if (res.ok) socket.emit(\"createStack\", name, ...);\n});","handlingStrategy":"type-guard","validationCode":"// client-side: only emit protected events with an authenticated socket\nif (socket.userID) {\n  socket.emit(\"createStack\", name, composeYAML);\n} else {\n  redirectToLogin();\n}","typeGuard":"function isLoggedIn(socket) {\n  return typeof socket.userID === \"string\" && socket.userID.length > 0;\n}","tryCatchPattern":"try {\n  checkLogin(socket);\n  // ... protected handler body\n} catch (e) {\n  if (e.message === \"You are not logged in.\") {\n    socket.emit(\"authError\", \"Please log in again.\"); // prompt re-login client-side\n  } else throw e;\n}","preventionTips":["Re-authenticate/reload after any Dockge server restart","In automation, always perform the login handshake before other socket calls","Handle token expiry by re-login instead of retrying protected calls","Check socket.userID before invoking handlers that guard with checkLogin"],"tags":["authentication","websocket","session","authorization"],"backgroundTag":"not-authenticated","analyzedSha":"f809ae192b571944ad773e9866d3e67064ae8043","analyzedAt":"2026-08-31T19:13:50.919Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}