{"record":{"id":"3d60939d4eee58d6","repo":"vxcontrol/pentagi","slug":"user-is-not-ready","errorCode":null,"errorMessage":"user is not ready","messagePattern":"user is not ready","errorType":"http","errorClass":null,"httpStatus":401,"severity":"warning","filePath":"backend/pkg/server/auth/auth_middleware.go","lineNumber":170,"sourceCode":"\t}\n\n\t// Verify user hash matches database\n\tuserID := uid.(uint64)\n\tsessionHash := uhash.(string)\n\n\tdbHash, userStatus, err := p.userCache.GetUserHash(userID)\n\tif err != nil {\n\t\tif errors.Is(err, gorm.ErrRecordNotFound) {\n\t\t\treturn authResultFail, errors.New(\"user has been deleted\")\n\t\t}\n\t\treturn authResultFail, fmt.Errorf(\"error checking user status: %w\", err)\n\t}\n\n\tswitch userStatus {\n\tcase models.UserStatusBlocked:\n\t\treturn authResultFail, errors.New(\"user has been blocked\")\n\tcase models.UserStatusCreated:\n\t\treturn authResultFail, errors.New(\"user is not ready\")\n\tcase models.UserStatusActive:\n\t}\n\n\tif dbHash != sessionHash {\n\t\treturn authResultFail, fmt.Errorf(\"%w - session invalid for this installation\", errUserHashMismatch)\n\t}\n\n\tc.Set(\"prm\", prms)\n\tc.Set(\"uid\", userID)\n\tc.Set(\"uhash\", sessionHash)\n\tc.Set(\"rid\", rid.(uint64))\n\tc.Set(\"exp\", exp.(int64))\n\tc.Set(\"gtm\", gtm.(int64))\n\tc.Set(\"tid\", tid.(string))\n\tc.Set(\"uname\", uname.(string))\n\n\tif slices.Contains(prms, PrivilegeAutomation) {\n\t\tc.Set(\"cpt\", \"automation\")","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/server/auth/auth_middleware.go#L152-L188","documentation":"Users in UserStatusCreated (registered but not yet activated/approved) are rejected with 'user is not ready'. The middleware only accepts UserStatusActive; anything earlier in the lifecycle is denied until the account is activated (e.g. email verification or admin approval).","triggerScenarios":"Logging in or calling authenticated APIs with an account that completed registration but has not been activated — pending email verification, pending admin approval, or a provisioning pipeline that left the user in 'created'.","commonSituations":"Self-registration flows where activation emails bounce or are never sent; staging environments where the approval step is skipped; importing users into the DB without setting status to active.","solutions":["Complete the activation step (verify email / wait for admin approval)","Have an admin set the user's status to active in the users table or via admin tooling","If provisioning users programmatically, ensure the status is set to active after creation"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await api.call();\n} catch (e) {\n  if (e.response?.status === 401 || e.response?.status === 403) {\n    showError('Your account is not yet active. Complete verification or wait for approval.');\n  }\n}","preventionTips":["Complete email verification / approval immediately after registering","Ensure automated user provisioning sets status to active at the end of the pipeline","Poll or refresh after completing activation instead of retrying the same request"],"tags":["authentication","user-status","onboarding"],"backgroundTag":"account-not-activated","analyzedSha":"ea665308baaff015b226f308438a68d929d0f29b","analyzedAt":"2026-09-01T14:16:31.421Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}