Leantime/leantime · error · \Exception

User must be authenticated to create token

Error message

User must be authenticated to create token

What it means

Error "User must be authenticated to create token" thrown in Leantime/leantime.

Source

Thrown at app/Domain/Auth/Services/Auth.php:254

            self::dispatch_event('afterLoginCheck', ['username' => $username, 'password' => $password, 'authService' => app()->make(self::class)]);

            return true;
        } else {
            $this->logFailedLogin($username);
            self::dispatch_event('afterLoginCheck', ['username' => $username, 'password' => $password, 'authService' => app()->make(self::class)]);

            return false;
        }
    }

    /**
     * Create a new personal access token
     */
    public function createToken(string $name, array $abilities = ['*']): array
    {
        if (! $this->loggedIn()) {
            throw new \Exception('User must be authenticated to create token');
        }

        return $this->tokenRepo->createToken($this->getUserId(), $name, $abilities);
    }

    /**
     * @return false|void
     *
     * @throws BindingResolutionException
     */
    public function setUserSession(mixed $user, bool $isExternalAuth = false)
    {
        if (! $user || ! is_array($user)) {
            return false;
        }

        // Web-login session. twoFAVerified: false — the web flow enforces interactive 2FA via the
        // AuthCheck gate. Built via the shared factory (role NAME string + consistent fields), with

View on GitHub (pinned to 9a9f49f100)

When it happens

Trigger: Thrown at app/Domain/Auth/Services/Auth.php:254 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


AI-assisted analysis of Leantime/leantime@9a9f49f100 (2026-08-21). Data as JSON: /api/errors/35d3c196e8a884fd. Report an issue: GitHub.