{"record":{"id":"3ac4538c5bce7fa6","repo":"BookStackApp/BookStack","slug":"token-token-not-found","errorCode":null,"errorMessage":"Token \"' . $token . '\" not found\"","messagePattern":"Token \"' \\. \\$token \\. '\" not found\"","errorType":"exception","errorClass":"UserTokenNotFoundException","httpStatus":null,"severity":"error","filePath":"app/Access/UserTokenService.php","lineNumber":46,"sourceCode":"    public function deleteByUser(User $user): void\n    {\n        DB::table($this->tokenTable)\n            ->where('user_id', '=', $user->id)\n            ->delete();\n    }\n\n    /**\n     * Get the user id from a token, while checking the token exists and has not expired.\n     *\n     * @throws UserTokenNotFoundException\n     * @throws UserTokenExpiredException\n     */\n    public function checkTokenAndGetUserId(string $token): int\n    {\n        $entry = $this->getEntryByToken($token);\n\n        if (is_null($entry)) {\n            throw new UserTokenNotFoundException('Token \"' . $token . '\" not found');\n        }\n\n        if ($this->entryExpired($entry)) {\n            throw new UserTokenExpiredException(\"Token of id {$entry->id} has expired.\", $entry->user_id);\n        }\n\n        return $entry->user_id;\n    }\n\n    /**\n     * Creates a unique token within the email confirmation database.\n     */\n    protected function generateToken(): string\n    {\n        $token = Str::random(24);\n        while ($this->tokenExists($token)) {\n            $token = Str::random(25);\n        }","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/BookStackApp/BookStack/blob/18f8469a1c72f8cc8497e9372635e6dea5028071/app/Access/UserTokenService.php#L28-L64","documentation":"UserTokenNotFoundException raised by checkTokenAndGetUserId when getEntryByToken finds no row matching the supplied token string in the token table. Input at fault: an unknown, already-deleted, or mistyped token value.","triggerScenarios":"Thrown at app/Access/UserTokenService.php:46 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ask the user to re-request the invite/password-reset link so a fresh token is generated","Confirm the URL's token matches exactly (no truncation or extra whitespace)","Check the token table for the record; it may have been deleted by a later token generation"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"18f8469a1c72f8cc8497e9372635e6dea5028071","analyzedAt":"2026-09-02T19:49:33.068Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}