Skip to content

Commit 9c38796

Browse files
committed
feat: add isOAuth property to Props and update authentication logic, fix for incorrect user type detection
1 parent 8b5a90b commit 9c38796

3 files changed

Lines changed: 4 additions & 1 deletion

File tree

src/app.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ app.get("/auth/callback", async (c) => {
261261
state,
262262
userName: userData.username,
263263
isAuthenticated: true,
264+
isOAuth: true,
264265
},
265266
});
266267

src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ For more information, visit: https://www.globalping.io
385385
userData: Record<string, any>;
386386
} {
387387
const isAuth = this.props?.isAuthenticated;
388-
const hasAPIToken = this.props?.accessToken && isValidAPIToken(this.props.accessToken);
388+
const hasAPIToken = !this.props?.isOAuth;
389389

390390
// Check API token first (most specific) to prevent misclassification
391391
// as OAuth when API token flow sets isAuthenticated and userName
@@ -550,6 +550,7 @@ async function handleAPITokenRequest<
550550
userName: "API Token User",
551551
clientId: "",
552552
isAuthenticated: true,
553+
isOAuth: false,
553554
} satisfies Props;
554555

555556
if (pathname === MCP_CONFIG.ROUTES.SSE || pathname === MCP_CONFIG.ROUTES.SSE_MESSAGE) {

src/types/app.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export type Props = {
55
userName: string;
66
clientId: string;
77
isAuthenticated: boolean;
8+
isOAuth: boolean;
89
};
910

1011
// Define custom state for storing previous measurements

0 commit comments

Comments
 (0)