{"record":{"id":"06952098722d8a67","repo":"gitroomhq/postiz-app","slug":"account-is-already-activated","errorCode":null,"errorMessage":"Account is already activated","messagePattern":"Account is already activated","errorType":"error_code","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"apps/backend/src/services/auth/auth.service.ts","lineNumber":276,"sourceCode":"      await this._userService.activateUser(user.id);\n      user.activated = true;\n      this._track('register', user.email, tracking).catch((err) => {});\n      await NewsletterService.register(user.email);\n      return this.jwt(user as any);\n    }\n\n    return false;\n  }\n\n  async resendActivationEmail(email: string) {\n    const user = await this._userService.getUserByEmail(email);\n\n    if (!user) {\n      throw new Error('User not found');\n    }\n\n    if (user.activated) {\n      throw new Error('Account is already activated');\n    }\n\n    const jwt = await this.jwt(user);\n\n    await this._emailService.sendEmail(\n      user.email,\n      'Activate your account',\n      `Click <a href=\"${process.env.FRONTEND_URL}/auth/activate/${jwt}\">here</a> to activate your account`,\n      'top'\n    );\n\n    return true;\n  }\n\n  oauthLink(provider: string, query?: any) {\n    const providerInstance = this._providerManager.getProvider(provider);\n    return providerInstance.generateLink(query);\n  }","sourceCodeStart":258,"sourceCodeEnd":294,"githubUrl":"https://github.com/gitroomhq/postiz-app/blob/0f1647f7491a217d43eb5ae7a480484bdf0aff3e/apps/backend/src/services/auth/auth.service.ts#L258-L294","documentation":"Thrown by resendActivationEmail when the target user record already has its 'activated' flag set. The service refuses to generate and send a new activation JWT for an account that no longer needs one. This is a domain-state guard, not a bug indicator.","triggerScenarios":"Calling the resend-activation endpoint with the email/identifier of a user whose `user.activated` is true in the database (e.g. POST /auth/resend-activation after the user already clicked the activation link).","commonSituations":"User double-clicks the resend button after activating in another tab; frontend keeps a stale 'not activated' state; testing with a seed account that is already activated.","solutions":["Confirm the user actually needs activation (check the activated column) before calling the endpoint","Have the frontend refresh user state after activation and hide the 'resend email' button","Treat this error as a 200-level 'nothing to do' case in the controller / UI instead of showing a failure","Audit for accidental re-use of the resend flow as a login trigger"],"exampleFix":"// before\nawait authService.resendActivationEmail(user.email);\n\n// after\nconst user = await userService.getUserByEmail(email);\nif (user?.activated) {\n  return { alreadyActivated: true };\n}\nawait authService.resendActivationEmail(email);","handlingStrategy":"validation","validationCode":"const user = await userService.getUserByEmail(email);\nif (!user || user.activated) {\n  // nothing to send\n  return { ok: true, alreadyActivated: Boolean(user?.activated) };\n}\nawait authService.resendActivationEmail(email);","typeGuard":"const isUnactivatedUser = (u: User | null): u is User & { activated: false } =>\n  !!u && typeof u.activated === 'boolean' && !u.activated;","tryCatchPattern":"try {\n  await authService.resendActivationEmail(email);\n} catch (e) {\n  if (e instanceof Error && e.message === 'Account is already activated') return { ok: true };\n  throw e;\n}","preventionTips":["Refresh user state after activation completes before showing resend UI","Disable the resend button once activation succeeds"],"tags":["auth","activation","user-state"],"backgroundTag":"account-already-activated","analyzedSha":"0f1647f7491a217d43eb5ae7a480484bdf0aff3e","analyzedAt":"2026-08-27T12:09:55.020Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}