Skip to content

Commit ad0380a

Browse files
committed
fix: restore oauth callback validation type
1 parent 7c11022 commit ad0380a

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

apps/backend/src/routes/auth.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { generateRefreshToken, hashIp, hashRefreshToken } from '../utils/refresh
55
import { oAuthStartSchema } from '../validations/auth.validation.js';
66

77
import type { GitHubTokenErrorResponse, GitHubTokenResponse } from '../utils/error.util.js';
8-
import type { OAuthStartQuery } from '../validations/auth.validation.js';
8+
import type { OAuthCallbackQuery, OAuthStartQuery } from '../validations/auth.validation.js';
99
import type { FastifyInstance, FastifyRequest, FastifyReply } from 'fastify';
1010

1111
interface GitHubEmailResponse {
@@ -21,11 +21,6 @@ const GOOGLE_AUTH_URL = 'https://accounts.google.com/o/oauth2/v2/auth';
2121
const GOOGLE_TOKEN_URL = 'https://oauth2.googleapis.com/token';
2222
const GOOGLE_USER_URL = 'https://www.googleapis.com/oauth2/v2/userinfo';
2323

24-
interface OAuthCallbackQuery {
25-
code: string;
26-
state?: string;
27-
}
28-
2924
interface GoogleUser {
3025
id: string;
3126
email: string;

apps/backend/src/validations/auth.validation.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,11 @@ export const oAuthStartSchema = z.object({
1212
),
1313
});
1414

15-
export type OAuthStartQuery = z.infer<typeof oAuthStartSchema>;
15+
export type OAuthStartQuery = z.infer<typeof oAuthStartSchema>;
16+
17+
export const oAuthCallbackSchema = z.object({
18+
code: z.string().trim().min(1, 'Authorization code is required'),
19+
state: z.string().trim().min(1, 'State parameter is required'),
20+
});
21+
22+
export type OAuthCallbackQuery = z.infer<typeof oAuthCallbackSchema>;

0 commit comments

Comments
 (0)