File tree Expand file tree Collapse file tree 5 files changed +20
-4
lines changed
packages/internal/src/utils
web/src/app/api/auth/cli/logout Expand file tree Collapse file tree 5 files changed +20
-4
lines changed Original file line number Diff line number Diff line change 11import { findOrganizationForRepository } from '@codebuff/billing'
22import { z } from 'zod/v4'
3+ import { INVALID_AUTH_TOKEN_MESSAGE } from '@codebuff/common/constants'
34
45import { logger } from '../util/logger'
56import { extractAuthTokenFromHeader } from '../util/auth-helpers'
@@ -37,7 +38,7 @@ async function isRepoCoveredHandler(
3738 const userId = await getUserIdFromAuthToken ( authToken )
3839
3940 if ( ! userId ) {
40- return res . status ( 401 ) . json ( { error : 'Invalid authentication token' } )
41+ return res . status ( 401 ) . json ( { error : INVALID_AUTH_TOKEN_MESSAGE } )
4142 }
4243
4344 // Check if repository is covered by an organization
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import db from '@codebuff/common/db'
33import * as schema from '@codebuff/common/db/schema'
44import { eq } from 'drizzle-orm'
55import { z } from 'zod/v4'
6+ import { INVALID_AUTH_TOKEN_MESSAGE } from '@codebuff/common/constants'
67
78import { checkAuth } from '../util/check-auth'
89import { logger } from '../util/logger'
@@ -61,7 +62,10 @@ async function usageHandler(
6162 : undefined
6263
6364 if ( ! userId ) {
64- return res . status ( 401 ) . json ( { message : 'Authentication failed' } )
65+ const message = authToken
66+ ? INVALID_AUTH_TOKEN_MESSAGE
67+ : 'Authentication failed'
68+ return res . status ( 401 ) . json ( { message } )
6569 }
6670
6771 // If orgId is provided, return organization usage data
Original file line number Diff line number Diff line change @@ -10,6 +10,9 @@ export const AGENT_DEFINITION_FILE = 'agent-definition.d.ts'
1010
1111export const API_KEY_ENV_VAR = 'CODEBUFF_API_KEY'
1212
13+ export const INVALID_AUTH_TOKEN_MESSAGE =
14+ 'Invalid auth token. You may have been logged out from the web portal. Please log in again.'
15+
1316// Enable async agents to run tool calls even when main user input is cancelled
1417export const ASYNC_AGENTS_ENABLED = true
1518
Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ import db from '@codebuff/common/db'
22import * as schema from '@codebuff/common/db/schema'
33import { eq } from 'drizzle-orm'
44
5+ import { INVALID_AUTH_TOKEN_MESSAGE } from '@codebuff/common/constants'
6+
57// List of admin user emails - single source of truth
68const CODEBUFF_ADMIN_USER_EMAILS = [
79 'venkateshrameshkumar+1@gmail.com' ,
@@ -81,7 +83,7 @@ export async function checkAuthToken({
8183 success : false ,
8284 error : {
8385 type : 'invalid-token' ,
84- message : 'Invalid auth token' ,
86+ message : INVALID_AUTH_TOKEN_MESSAGE ,
8587 } ,
8688 }
8789 }
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import * as schema from '@codebuff/common/db/schema'
33import { and , eq } from 'drizzle-orm'
44import { NextResponse } from 'next/server'
55import { z } from 'zod/v4'
6+ import { INVALID_AUTH_TOKEN_MESSAGE } from '@codebuff/common/constants'
67
78import { logger } from '@/util/logger'
89
@@ -36,7 +37,12 @@ export async function POST(req: Request) {
3637 } )
3738
3839 if ( validDeletion . length === 0 ) {
39- return NextResponse . json ( { error : 'Invalid session' } , { status : 401 } )
40+ return NextResponse . json (
41+ {
42+ error : INVALID_AUTH_TOKEN_MESSAGE ,
43+ } ,
44+ { status : 401 }
45+ )
4046 }
4147
4248 // Then reset sig_hash to null
You can’t perform that action at this time.
0 commit comments