Repository navigation
Feat/auth component support - #531
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughExposes the OAuth configs endpoint publicly, adds SPA routing for /auth* on the server, and implements a frontend auth feature set: SignIn/SignUp pages, reusable auth components (form fields, password/strength, submit, OAuth providers), validation schemas, small CSS update, and docs entry. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Browser
participant FrontendApp
participant Backend
participant OAuthProvider
rect rgba(200,220,255,0.6)
Note over User,FrontendApp: Load auth UI
User->>Browser: Navigate to /auth/signin or /auth/signup
Browser->>FrontendApp: SPA route -> Sign page
FrontendApp->>Backend: GET /api/auth/oauth/configs
Backend-->>FrontendApp: provider list
FrontendApp-->>User: render form + provider buttons
end
rect rgba(220,240,220,0.6)
Note over User,Backend: Email/password flow
User->>FrontendApp: Submit credentials
FrontendApp->>Backend: POST /api/auth/sessions or /api/auth/users
Backend-->>FrontendApp: access_token
FrontendApp->>Browser: redirect (append access_token)
end
rect rgba(255,235,205,0.6)
Note over User,OAuthProvider: OAuth flow
User->>FrontendApp: Click provider
FrontendApp->>Backend: GET /api/auth/oauth/{provider}?redirect_uri=...
Backend-->>FrontendApp: provider authUrl
FrontendApp->>Browser: redirect -> OAuthProvider
OAuthProvider-->>Backend: callback with code
Backend-->>Browser: final redirect with access_token
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 7
🧹 Nitpick comments (12)
frontend/src/features/auth/components/AuthPasswordField.tsx (4)
52-59: Input className from consumers is being droppedBecause you destructure className for the wrapper, Input’s className from props is overridden by "pr-10". Expose a dedicated inputClassName and merge via cn to avoid losing consumer styles.
Apply:
- interface AuthPasswordFieldProps extends React.InputHTMLAttributes<HTMLInputElement> { + interface AuthPasswordFieldProps extends React.InputHTMLAttributes<HTMLInputElement> { label?: string; showStrengthIndicator?: boolean; forgotPasswordLink?: { href: string; text?: string; }; + inputClassName?: string; } @@ -export function AuthPasswordField({ +export function AuthPasswordField({ label = 'Password', id, - className, + className, showStrengthIndicator = false, forgotPasswordLink, value, onFocus, + inputClassName, ...props }: AuthPasswordFieldProps) { @@ - <Input + <Input {...props} id={id} type={showPassword ? 'text' : 'password'} - className="pr-10" + className={cn('pr-10', inputClassName)} value={value} onFocus={handleFocus} />
60-67: Improve toggle accessibilityExpose pressed state for assistive tech.
- <button + <button type="button" onClick={() => setShowPassword(!showPassword)} className="absolute right-3 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200" - aria-label={showPassword ? 'Hide password' : 'Show password'} + aria-label={showPassword ? 'Hide password' : 'Show password'} + aria-pressed={showPassword} >
1-7: Generate a stable id when none is passedUse React’s useId so Label htmlFor always matches Input, avoiding duplicate-id and missing-id issues.
-import { useState } from 'react'; +import { useId, useState } from 'react'; @@ export function AuthPasswordField({ label = 'Password', id, @@ }: AuthPasswordFieldProps) { + const generatedId = useId(); + const inputId = id ?? generatedId; @@ - <Label htmlFor={id} className="text-sm font-medium text-gray-700 dark:text-gray-300"> + <Label htmlFor={inputId} className="text-sm font-medium text-gray-700 dark:text-gray-300"> {label} </Label> @@ - id={id} + id={inputId}Also applies to: 17-26, 40-55
45-49: Router-friendly forgot password navigationIf href points to an internal route, prefer from react-router to avoid full page reloads. If external, keep but add rel="noopener noreferrer" when target="_blank".
frontend/src/features/auth/components/AuthOAuthProviders.tsx (1)
84-87: Grid span shorthand may not span as intendedgridColumn: 'span 2' can be ambiguous; use 'span 2 / span 2' to ensure 2-column span, or Tailwind col-span-* classes.
- return { gridColumn: 'span 2' }; + return { gridColumn: 'span 2 / span 2' }; @@ - return { gridColumn: 'span 2' }; + return { gridColumn: 'span 2 / span 2' }; @@ - return { gridColumn: 'span 2' }; + return { gridColumn: 'span 2 / span 2' };Alternatively, compute className "col-span-2|3|6" and drop inline styles for better readability and theming consistency.
Also applies to: 99-121
frontend/src/features/auth/page/SignUpPage.tsx (3)
126-132: UI nits: Tailwind class and width token
- bg-linear-to-br isn’t a Tailwind utility; use bg-gradient-to-br.
- w-21 isn’t a default width token; use an arbitrary value or nearest scale.
- <div className="min-h-screen flex items-center justify-center bg-linear-to-br from-gray-50 to-gray-100 dark:from-neutral-900 dark:to-neutral-800"> + <div className="min-h-screen flex items-center justify-center bg-gradient-to-br from-gray-50 to-gray-100 dark:from-neutral-900 dark:to-neutral-800"> @@ - <a href="https://insforge.dev" target="_blank" rel="noopener noreferrer"> - <InsForgeLogo className="w-21 h-5" /> + <a href="https://insforge.dev" target="_blank" rel="noopener noreferrer"> + <InsForgeLogo className="w-[84px] h-5" /> </a>Also applies to: 208-214
29-41: Prefer TanStack Query for server stateFetching providers on mount bypasses the shared cache and retry/timeout policies. Use useQuery with a keyed cache and proper error UI, per repo guidelines.
143-176: Forms: adopt React Hook Form + Zod for validationManual state + regex validation is fine short-term but diverges from the project’s form stack and makes reuse harder. Consider RHF + Zod for consistent rules and error messaging.
frontend/src/features/auth/components/AuthSubmitButton.tsx (1)
18-29: Expose busy state to assistive techAdd aria-busy and aria-live so screen readers get progress feedback.
- <Button + <Button {...props} type="submit" disabled={disabled || isLoading} + aria-busy={!!isLoading} + aria-live="polite" className={cn( 'mt-4 px-4 py-2 rounded w-full h-10 bg-black hover:bg-gray-800 dark:bg-white dark:hover:bg-gray-200 dark:text-black', className )} > - {isLoading && <Loader2 className="w-4 h-4 animate-spin" />} + {isLoading && <Loader2 className="w-4 h-4 animate-spin" aria-hidden="true" />} {children} </Button>frontend/src/features/auth/page/SignInPage.tsx (3)
115-121: UI nits: Tailwind gradient and width tokenFix the gradient utility and logo width token.
- <div className="min-h-screen flex items-center justify-center bg-linear-to-br from-gray-50 to-gray-100 dark:from-neutral-900 dark:to-neutral-800"> + <div className="min-h-screen flex items-center justify-center bg-gradient-to-br from-gray-50 to-gray-100 dark:from-neutral-900 dark:to-neutral-800"> @@ - <InsForgeLogo className="w-21 h-5" /> + <InsForgeLogo className="w-[84px] h-5" />Also applies to: 194-199
28-41: Prefer TanStack Query for providersUse useQuery for '/api/auth/oauth/configs' with caching and error states.
132-158: Adopt React Hook Form + Zod for input and validationAlign with project stack for consistency and better UX/accessibility.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (6)
frontend/src/assets/logos/apple.svgis excluded by!**/*.svgfrontend/src/assets/logos/discord.svgis excluded by!**/*.svgfrontend/src/assets/logos/instagram.svgis excluded by!**/*.svgfrontend/src/assets/logos/spotify.svgis excluded by!**/*.svgfrontend/src/assets/logos/tiktok.svgis excluded by!**/*.svgfrontend/src/assets/logos/x.svgis excluded by!**/*.svg
📒 Files selected for processing (13)
backend/src/api/routes/auth.oauth.ts(1 hunks)backend/src/server.ts(1 hunks)frontend/src/features/auth/components/AuthFormField.tsx(1 hunks)frontend/src/features/auth/components/AuthMethodTab.tsx(1 hunks)frontend/src/features/auth/components/AuthOAuthProviders.tsx(1 hunks)frontend/src/features/auth/components/AuthPasswordField.tsx(1 hunks)frontend/src/features/auth/components/AuthPasswordStrengthIndicator.tsx(1 hunks)frontend/src/features/auth/components/AuthSubmitButton.tsx(1 hunks)frontend/src/features/auth/components/index.ts(1 hunks)frontend/src/features/auth/page/SignInPage.tsx(1 hunks)frontend/src/features/auth/page/SignUpPage.tsx(1 hunks)frontend/src/index.css(1 hunks)frontend/src/lib/routing/AppRoutes.tsx(1 hunks)
🧰 Additional context used
📓 Path-based instructions (9)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.{ts,tsx}: Use TypeScript for all code files
Use ES modules (import/export syntax)
Prefer descriptive, unabbreviated variable and function names
Implement proper error handling with try-catch blocks and logging where appropriate
Use single quotes for strings
Include semicolons at the end of statements
Use arrow functions for callbacks and inline functions
Prefer const over let; avoid var
Use template literals for string interpolation
Maintain 2-space indentation
Format code with the repository Prettier configuration
Variables, parameters, properties, and functions must use camelCase
Constants and enum members must use UPPER_CASE
Include JSDoc comments for complex functions
Files:
frontend/src/features/auth/components/AuthFormField.tsxbackend/src/server.tsfrontend/src/features/auth/components/AuthPasswordStrengthIndicator.tsxfrontend/src/features/auth/components/index.tsfrontend/src/features/auth/components/AuthPasswordField.tsxfrontend/src/features/auth/components/AuthOAuthProviders.tsxbackend/src/api/routes/auth.oauth.tsfrontend/src/lib/routing/AppRoutes.tsxfrontend/src/features/auth/page/SignInPage.tsxfrontend/src/features/auth/page/SignUpPage.tsxfrontend/src/features/auth/components/AuthMethodTab.tsxfrontend/src/features/auth/components/AuthSubmitButton.tsx
frontend/src/**/*.{tsx,ts}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
frontend/src/**/*.{tsx,ts}: Use functional React components with hooks exclusively
Use Radix UI primitives for accessibility
Optimize React component re-renders
Files:
frontend/src/features/auth/components/AuthFormField.tsxfrontend/src/features/auth/components/AuthPasswordStrengthIndicator.tsxfrontend/src/features/auth/components/index.tsfrontend/src/features/auth/components/AuthPasswordField.tsxfrontend/src/features/auth/components/AuthOAuthProviders.tsxfrontend/src/lib/routing/AppRoutes.tsxfrontend/src/features/auth/page/SignInPage.tsxfrontend/src/features/auth/page/SignUpPage.tsxfrontend/src/features/auth/components/AuthMethodTab.tsxfrontend/src/features/auth/components/AuthSubmitButton.tsx
frontend/src/**/*.tsx
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
frontend/src/**/*.tsx: Implement TypeScript interfaces/types for all component props
Follow component composition patterns; keep components focused and single-purpose
Implement proper loading and error states in UI
Use a consistent icon set from lucide-react
Files:
frontend/src/features/auth/components/AuthFormField.tsxfrontend/src/features/auth/components/AuthPasswordStrengthIndicator.tsxfrontend/src/features/auth/components/AuthPasswordField.tsxfrontend/src/features/auth/components/AuthOAuthProviders.tsxfrontend/src/lib/routing/AppRoutes.tsxfrontend/src/features/auth/page/SignInPage.tsxfrontend/src/features/auth/page/SignUpPage.tsxfrontend/src/features/auth/components/AuthMethodTab.tsxfrontend/src/features/auth/components/AuthSubmitButton.tsx
frontend/src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
frontend/src/**/*.{ts,tsx}: Use TanStack Query for server state management
Use React Hook Form for form handling with Zod validation
Optimize bundle size with proper imports
Files:
frontend/src/features/auth/components/AuthFormField.tsxfrontend/src/features/auth/components/AuthPasswordStrengthIndicator.tsxfrontend/src/features/auth/components/index.tsfrontend/src/features/auth/components/AuthPasswordField.tsxfrontend/src/features/auth/components/AuthOAuthProviders.tsxfrontend/src/lib/routing/AppRoutes.tsxfrontend/src/features/auth/page/SignInPage.tsxfrontend/src/features/auth/page/SignUpPage.tsxfrontend/src/features/auth/components/AuthMethodTab.tsxfrontend/src/features/auth/components/AuthSubmitButton.tsx
**/*.{tsx,ts}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
React components and TypeScript types/interfaces must use PascalCase
Files:
frontend/src/features/auth/components/AuthFormField.tsxbackend/src/server.tsfrontend/src/features/auth/components/AuthPasswordStrengthIndicator.tsxfrontend/src/features/auth/components/index.tsfrontend/src/features/auth/components/AuthPasswordField.tsxfrontend/src/features/auth/components/AuthOAuthProviders.tsxbackend/src/api/routes/auth.oauth.tsfrontend/src/lib/routing/AppRoutes.tsxfrontend/src/features/auth/page/SignInPage.tsxfrontend/src/features/auth/page/SignUpPage.tsxfrontend/src/features/auth/components/AuthMethodTab.tsxfrontend/src/features/auth/components/AuthSubmitButton.tsx
frontend/src/**/[A-Z]*.tsx
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Component files must use PascalCase filenames (e.g., DataGrid.tsx)
Files:
frontend/src/features/auth/components/AuthFormField.tsxfrontend/src/features/auth/components/AuthPasswordStrengthIndicator.tsxfrontend/src/features/auth/components/AuthPasswordField.tsxfrontend/src/features/auth/components/AuthOAuthProviders.tsxfrontend/src/lib/routing/AppRoutes.tsxfrontend/src/features/auth/page/SignInPage.tsxfrontend/src/features/auth/page/SignUpPage.tsxfrontend/src/features/auth/components/AuthMethodTab.tsxfrontend/src/features/auth/components/AuthSubmitButton.tsx
backend/src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
backend/src/**/*.{ts,tsx}: Use async/await for asynchronous operations in the backend
Use Zod schemas for request/response validation
Return consistent API responses using utility functions
Validate all user inputs
Sanitize data before database operations
Use prepared statements for SQL queries
Implement proper caching strategies (server-side)
Files:
backend/src/server.tsbackend/src/api/routes/auth.oauth.ts
**/[a-z][a-z0-9-]*.ts
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Utility files should use kebab-case or camelCase (kebab-case validated here)
Files:
backend/src/server.tsfrontend/src/features/auth/components/index.tsbackend/src/api/routes/auth.oauth.ts
backend/src/api/**/*.ts
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
backend/src/api/**/*.ts: Implement authentication and error-handling middleware
Follow RESTful conventions for API endpoints
Implement rate limiting for API endpoints
Files:
backend/src/api/routes/auth.oauth.ts
🧬 Code graph analysis (8)
frontend/src/features/auth/components/AuthFormField.tsx (1)
frontend/src/lib/utils/utils.ts (1)
cn(19-21)
frontend/src/features/auth/components/AuthPasswordStrengthIndicator.tsx (1)
frontend/src/features/auth/components/index.ts (2)
validatePasswordStrength(5-5)AuthPasswordStrengthIndicator(4-4)
frontend/src/features/auth/components/AuthPasswordField.tsx (2)
frontend/src/lib/utils/utils.ts (1)
cn(19-21)frontend/src/features/auth/components/AuthPasswordStrengthIndicator.tsx (1)
AuthPasswordStrengthIndicator(44-62)
frontend/src/features/auth/components/AuthOAuthProviders.tsx (3)
shared-schemas/src/auth.schema.ts (1)
OAuthProvidersSchema(107-107)frontend/src/features/auth/components/index.ts (1)
AuthOAuthProviders(8-8)frontend/src/components/radix/Button.tsx (1)
Button(50-50)
frontend/src/lib/routing/AppRoutes.tsx (2)
frontend/src/features/auth/page/SignInPage.tsx (1)
SignInPage(17-203)frontend/src/features/auth/page/SignUpPage.tsx (1)
SignUpPage(17-218)
frontend/src/features/auth/page/SignInPage.tsx (6)
shared-schemas/src/auth.schema.ts (2)
OAuthProvidersSchema(107-107)OAuthConfigSchema(106-106)shared-schemas/src/auth-api.schema.ts (1)
ListOAuthConfigsResponse(191-191)frontend/src/features/auth/components/AuthFormField.tsx (1)
AuthFormField(9-20)frontend/src/features/auth/components/AuthPasswordField.tsx (1)
AuthPasswordField(17-74)frontend/src/features/auth/components/AuthSubmitButton.tsx (1)
AuthSubmitButton(10-31)frontend/src/features/auth/components/AuthOAuthProviders.tsx (1)
AuthOAuthProviders(46-148)
frontend/src/features/auth/page/SignUpPage.tsx (6)
shared-schemas/src/auth.schema.ts (2)
OAuthProvidersSchema(107-107)OAuthConfigSchema(106-106)shared-schemas/src/auth-api.schema.ts (1)
ListOAuthConfigsResponse(191-191)frontend/src/features/auth/components/AuthFormField.tsx (1)
AuthFormField(9-20)frontend/src/features/auth/components/AuthPasswordField.tsx (1)
AuthPasswordField(17-74)frontend/src/features/auth/components/AuthSubmitButton.tsx (1)
AuthSubmitButton(10-31)frontend/src/features/auth/components/AuthOAuthProviders.tsx (1)
AuthOAuthProviders(46-148)
frontend/src/features/auth/components/AuthSubmitButton.tsx (3)
frontend/src/features/auth/components/index.ts (1)
AuthSubmitButton(7-7)frontend/src/components/radix/Button.tsx (1)
Button(50-50)frontend/src/lib/utils/utils.ts (1)
cn(19-21)
🔇 Additional comments (14)
backend/src/server.ts (1)
262-264: LGTM! SPA routing for authentication paths.The new catch-all route for
/auth*paths is correctly implemented and consistent with the existing patterns for/cloud*and/dashboard*routes. This ensures the frontend SPA can handle client-side routing for the new authentication pages.frontend/src/features/auth/components/AuthMethodTab.tsx (3)
41-41: LGTM! Icon styling update.The Microsoft icon styling has been simplified by removing the
dark:text-whiteclass, likely for better visual consistency with the component's design system.
48-48: LGTM! Explicit Discord brand color.The Discord icon now uses explicit blue color (
text-[#3E4CD7]) for both light and dark modes, ensuring brand consistency.
55-55: LGTM! Icon styling simplification.The LinkedIn icon styling has been simplified by removing explicit text color classes, likely relying on default or inherited colors for better consistency.
frontend/src/lib/routing/AppRoutes.tsx (2)
18-19: LGTM! Import statements for authentication pages.The new imports for
SignInPageandSignUpPageare correctly added and follow the project's import conventions.
26-36: LGTM! Public authentication routes correctly configured.The new
/auth/*routing block is properly implemented:
- Not wrapped in
RequireAuth(correctly public)- Includes default redirect to
/auth/signin- Has catch-all redirect for unknown paths
- Uses nested
Routespattern consistent with other route groupsfrontend/src/features/auth/components/index.ts (1)
1-8: LGTM! Clean barrel exports for auth components.The barrel file properly consolidates exports for the new authentication components, improving import ergonomics across the codebase.
frontend/src/features/auth/components/AuthFormField.tsx (1)
1-20: LGTM! Well-structured reusable form field component.The
AuthFormFieldcomponent is properly implemented:
- Correctly extends
React.InputHTMLAttributesfor full input prop support- Uses Radix UI components for accessibility
- Conditionally renders label when provided
- Properly forwards all props to the Input component
- Follows project coding guidelines (functional component, TypeScript, proper naming)
frontend/src/features/auth/components/AuthPasswordStrengthIndicator.tsx (3)
34-39: LGTM! Clear validation utility.The
validatePasswordStrengthfunction correctly validates that a password meets all requirements. The empty password check prevents false positives.
44-62: LGTM! Clear visual feedback component.The component provides clear visual feedback by displaying each requirement with a check icon when satisfied or an empty circle when not. The implementation is straightforward and accessible.
12-29: LGTM! Comprehensive password requirements.The password requirements array defines four clear validation rules:
- Uppercase letter
- Number
- Special character (comprehensive regex)
- Minimum 8 characters
Ensure these frontend password requirements match the backend validation rules to prevent inconsistencies between client-side and server-side validation.
frontend/src/index.css (1)
63-63: Verify that the Manrope font is properly loaded.The new font variable
--fontFamilyManropeis defined, but ensure the Manrope font is imported via a@font-facerule or Google Fonts link. Based on the relevant code snippets, the new auth pages usefont-manropeclass, so the font must be available.Run the following script to check if Manrope is imported:
backend/src/api/routes/auth.oauth.ts (1)
482-496: Verify that sensitive OAuth credentials are not exposed in the public endpoint.The
/api/auth/oauth/configsendpoint has been changed from admin-only to public access, which is necessary for the frontend sign-in/sign-up pages to display available OAuth providers. However, ensure that the response does NOT include sensitive information such asclientSecret.Run the following script to verify that
getAllConfigs()doesn't return client secrets:Additionally, verify that the individual provider config endpoint (line 499-525) remains admin-protected, as it includes
clientSecreton line 509.frontend/src/features/auth/page/SignUpPage.tsx (1)
100-107: Reset oauthLoading on success navigation fallbackIf the backend responds with an error page instead of redirect, oauthLoading may remain set after user navigates back. Consider clearing it in a finally block.
Also applies to: 118-123
3f7fd1e to
04e577e
Compare
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
backend/src/api/routes/auth.oauth.ts (3)
251-305: Validate and allow‑list redirect_uri; consider rate limiting initredirect_uri is trusted and embedded into state without origin checks. Validate scheme (http/https), normalize against a known base, and enforce an allow‑list. Also, add rate limiting on OAuth init to reduce abuse.
Apply helper and usage:
@@ router.get('/:provider', async (req: Request, res: Response, next: NextFunction) => { try { const { provider } = req.params; - const { redirect_uri } = req.query; + const { redirect_uri } = req.query; @@ - if (!redirect_uri) { + if (!redirect_uri) { throw new AppError('Redirect URI is required', 400, ERROR_CODES.INVALID_INPUT); } @@ - const jwtPayload = { + const safeRedirect = parseAndValidateRedirectUri( + String(redirect_uri), + `${req.protocol}://${req.get('host')}` + ); + const jwtPayload = { provider: validatedProvider, - redirectUri: redirect_uri ? (redirect_uri as string) : undefined, + redirectUri: safeRedirect, createdAt: Date.now(), };Place this helper near validateJwtSecret:
// Normalize and allow-list redirect URIs function parseAndValidateRedirectUri(raw: string, base: string): string { let url: URL; try { url = new URL(raw, base); } catch { throw new AppError('Invalid redirectUri', 400, ERROR_CODES.INVALID_INPUT); } if (!['http:', 'https:'].includes(url.protocol)) { throw new AppError('Invalid redirectUri scheme', 400, ERROR_CODES.INVALID_INPUT); } const allowed = (process.env.AUTH_ALLOWED_REDIRECT_ORIGINS || '') .split(',') .map((s) => s.trim()) .filter(Boolean); if (allowed.length > 0 && !allowed.includes(url.origin)) { throw new AppError('redirectUri origin not allowed', 400, ERROR_CODES.INVALID_INPUT); } return url.toString(); }
307-442: Blocker: open redirect and token leakage in shared callbackTokens and PII are placed in query params and redirectUri is unguarded. Use hash fragments and validate redirectUri; also parse payload defensively.
@@ - let redirectUri: string; + let redirectUri: string; let provider: string; @@ - redirectUri = decodedState.redirectUri || ''; + redirectUri = parseAndValidateRedirectUri(decodedState.redirectUri || '', `${req.protocol}://${req.get('host')}`); @@ - if (success !== 'true') { + if (success !== 'true') { const errorMessage = error || 'OAuth Authentication Failed'; logger.warn('Shared OAuth callback failed', { error: errorMessage, provider }); - return res.redirect(`${redirectUri}/?error=${encodeURIComponent(String(errorMessage))}`); + const url = new URL(redirectUri); + url.hash = `error=${encodeURIComponent(String(errorMessage))}`; + return res.redirect(url.toString()); } @@ - const payloadData = JSON.parse(Buffer.from(payload as string, 'base64').toString('utf8')); + let payloadData: any; + try { + payloadData = JSON.parse(Buffer.from(payload as string, 'base64').toString('utf8')); + } catch { + throw new AppError('Invalid payload format', 400, ERROR_CODES.INVALID_INPUT); + } @@ - res.redirect(`${redirectUri}?${params.toString()}`); + const url = new URL(redirectUri); + url.hash = params.toString(); // Place tokens in fragment to avoid referrer leakage + return res.redirect(url.toString());
445-532: Blocker: provider callback also leaks tokens and lacks redirect allow‑listMirror the fixes: validate redirectUri from state, use fragment for tokens, and on error return error in fragment.
@@ - let redirectUri: string; + let redirectUri: string; @@ - redirectUri = stateData.redirectUri || ''; + redirectUri = parseAndValidateRedirectUri(stateData.redirectUri || '', `${req.protocol}://${req.get('host')}`); @@ - params.set('access_token', result?.accessToken ?? ''); + params.set('access_token', result?.accessToken ?? ''); params.set('user_id', result?.user.id ?? ''); params.set('email', result?.user.email ?? ''); params.set('name', result?.user.name ?? ''); @@ - const finalRedirectUri = `${redirectUri}?${params.toString()}`; + const url = new URL(redirectUri); + url.hash = params.toString(); + const finalRedirectUri = url.toString(); @@ - const params = new URLSearchParams(); + const params = new URLSearchParams(); params.set('error', errorMessage); - return res.redirect(`${redirectUri}?${params.toString()}`); + const url = new URL(redirectUri); + url.hash = params.toString(); + return res.redirect(url.toString());Add a lightweight rate limiter to the init/callback routes per backend guidelines.
♻️ Duplicate comments (4)
frontend/src/features/auth/page/SignUpPage.tsx (2)
72-75: Defensive error parsing for non‑JSON responsesAvoid throwing on non‑JSON bodies; parse safely and fall back to text/status.
- if (!response.ok) { - const errorData = await response.json(); - throw new Error((errorData as { message?: string }).message || 'Sign up failed'); - } + if (!response.ok) { + const text = await response.text().catch(() => ''); + let message = 'Sign up failed'; + try { message = (JSON.parse(text) as { message?: string }).message ?? message; } catch {} + throw new Error(message); + } @@ - if (!response.ok) { - const errorData = await response.json(); - throw new Error( - (errorData as { message?: string }).message || `${provider} OAuth initialization failed` - ); - } + if (!response.ok) { + const text = await response.text().catch(() => ''); + let message = `${provider} OAuth initialization failed`; + try { message = (JSON.parse(text) as { message?: string }).message ?? message; } catch {} + throw new Error(message); + }Also applies to: 112-117
104-108: Normalize redirect_uri to an absolute URLResolve potential relative/malformed redirectUrl to an absolute string before sending to backend.
- const finalRedirectUri = redirectUrl || window.location.origin; + const finalRedirectUri = (() => { + try { + return redirectUrl + ? new URL(redirectUrl, window.location.origin).toString() + : window.location.origin; + } catch { + return window.location.origin; + } + })();frontend/src/features/auth/page/SignInPage.tsx (2)
64-67: Defensive error parsing for non‑JSON responsesMirror SignUp changes to avoid masking original errors.
- if (!response.ok) { - const errorData = await response.json(); - throw new Error((errorData as { message?: string }).message || 'Sign in failed'); - } + if (!response.ok) { + const text = await response.text().catch(() => ''); + let message = 'Sign in failed'; + try { message = (JSON.parse(text) as { message?: string }).message ?? message; } catch {} + throw new Error(message); + } @@ - if (!response.ok) { - const errorData = await response.json(); - throw new Error( - (errorData as { message?: string }).message || `${provider} OAuth initialization failed` - ); - } + if (!response.ok) { + const text = await response.text().catch(() => ''); + let message = `${provider} OAuth initialization failed`; + try { message = (JSON.parse(text) as { message?: string }).message ?? message; } catch {} + throw new Error(message); + }Also applies to: 104-109
96-100: Normalize redirect_uri to absolute for OAuth initResolve redirectUrl safely before passing to backend.
- const finalRedirectUri = redirectUrl || window.location.origin; + const finalRedirectUri = (() => { + try { + return redirectUrl + ? new URL(redirectUrl, window.location.origin).toString() + : window.location.origin; + } catch { + return window.location.origin; + } + })();
🧹 Nitpick comments (3)
frontend/src/features/auth/components/AuthPasswordField.tsx (1)
36-41: Consider adding a blur handler to hide the strength indicator.The strength indicator is shown on focus but never hidden when the input loses focus. This means once visible, it remains visible throughout the form's lifecycle.
Consider adding a blur handler for better UX:
+ const handleBlur = (e: React.FocusEvent<HTMLInputElement>) => { + if (showStrengthIndicator) { + setShowStrength(false); + } + onBlur?.(e); + };Then update the Input component:
<Input {...props} id={inputId} type={showPassword ? 'text' : 'password'} className={cn('pr-10', inputClassName)} value={value} onFocus={handleFocus} + onBlur={handleBlur} />frontend/src/features/auth/page/SignUpPage.tsx (1)
43-97: Form handling with React Hook Form + ZodPer guidelines, consider React Hook Form with Zod schema for validations and error messaging consistency across auth forms.
As per coding guidelines
backend/src/api/routes/auth.oauth.ts (1)
40-53: Use successResponse utility for consistent response handlingThe endpoint correctly excludes sensitive fields from the query (clientSecret is not selected), so no data leak concern. However, align the response pattern with other OAuth routes by wrapping the response with
successResponse()instead ofres.json()directly:successResponse(res, { data: configs, count: configs.length, });This maintains consistency with the POST/PUT/DELETE endpoints on the same router (lines 132, 190, 235) and the rest of the codebase. Optionally, consider adding Cache-Control headers for this public endpoint if OAuth provider configs change infrequently.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (6)
frontend/src/assets/logos/apple.svgis excluded by!**/*.svgfrontend/src/assets/logos/discord.svgis excluded by!**/*.svgfrontend/src/assets/logos/instagram.svgis excluded by!**/*.svgfrontend/src/assets/logos/spotify.svgis excluded by!**/*.svgfrontend/src/assets/logos/tiktok.svgis excluded by!**/*.svgfrontend/src/assets/logos/x.svgis excluded by!**/*.svg
📒 Files selected for processing (12)
backend/src/api/routes/auth.oauth.ts(1 hunks)backend/src/server.ts(1 hunks)frontend/src/features/auth/components/AuthFormField.tsx(1 hunks)frontend/src/features/auth/components/AuthOAuthProviders.tsx(1 hunks)frontend/src/features/auth/components/AuthPasswordField.tsx(1 hunks)frontend/src/features/auth/components/AuthPasswordStrengthIndicator.tsx(1 hunks)frontend/src/features/auth/components/AuthSubmitButton.tsx(1 hunks)frontend/src/features/auth/components/index.ts(1 hunks)frontend/src/features/auth/page/SignInPage.tsx(1 hunks)frontend/src/features/auth/page/SignUpPage.tsx(1 hunks)frontend/src/index.css(1 hunks)frontend/src/lib/routing/AppRoutes.tsx(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
- backend/src/server.ts
- frontend/src/features/auth/components/AuthPasswordStrengthIndicator.tsx
- frontend/src/features/auth/components/AuthSubmitButton.tsx
- frontend/src/features/auth/components/index.ts
- frontend/src/features/auth/components/AuthFormField.tsx
🧰 Additional context used
📓 Path-based instructions (9)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.{ts,tsx}: Use TypeScript for all code files
Use ES modules (import/export syntax)
Prefer descriptive, unabbreviated variable and function names
Implement proper error handling with try-catch blocks and logging where appropriate
Use single quotes for strings
Include semicolons at the end of statements
Use arrow functions for callbacks and inline functions
Prefer const over let; avoid var
Use template literals for string interpolation
Maintain 2-space indentation
Format code with the repository Prettier configuration
Variables, parameters, properties, and functions must use camelCase
Constants and enum members must use UPPER_CASE
Include JSDoc comments for complex functions
Files:
backend/src/api/routes/auth.oauth.tsfrontend/src/features/auth/components/AuthOAuthProviders.tsxfrontend/src/lib/routing/AppRoutes.tsxfrontend/src/features/auth/components/AuthPasswordField.tsxfrontend/src/features/auth/page/SignInPage.tsxfrontend/src/features/auth/page/SignUpPage.tsx
backend/src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
backend/src/**/*.{ts,tsx}: Use async/await for asynchronous operations in the backend
Use Zod schemas for request/response validation
Return consistent API responses using utility functions
Validate all user inputs
Sanitize data before database operations
Use prepared statements for SQL queries
Implement proper caching strategies (server-side)
Files:
backend/src/api/routes/auth.oauth.ts
backend/src/api/**/*.ts
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
backend/src/api/**/*.ts: Implement authentication and error-handling middleware
Follow RESTful conventions for API endpoints
Implement rate limiting for API endpoints
Files:
backend/src/api/routes/auth.oauth.ts
**/*.{tsx,ts}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
React components and TypeScript types/interfaces must use PascalCase
Files:
backend/src/api/routes/auth.oauth.tsfrontend/src/features/auth/components/AuthOAuthProviders.tsxfrontend/src/lib/routing/AppRoutes.tsxfrontend/src/features/auth/components/AuthPasswordField.tsxfrontend/src/features/auth/page/SignInPage.tsxfrontend/src/features/auth/page/SignUpPage.tsx
**/[a-z][a-z0-9-]*.ts
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Utility files should use kebab-case or camelCase (kebab-case validated here)
Files:
backend/src/api/routes/auth.oauth.ts
frontend/src/**/*.{tsx,ts}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
frontend/src/**/*.{tsx,ts}: Use functional React components with hooks exclusively
Use Radix UI primitives for accessibility
Optimize React component re-renders
Files:
frontend/src/features/auth/components/AuthOAuthProviders.tsxfrontend/src/lib/routing/AppRoutes.tsxfrontend/src/features/auth/components/AuthPasswordField.tsxfrontend/src/features/auth/page/SignInPage.tsxfrontend/src/features/auth/page/SignUpPage.tsx
frontend/src/**/*.tsx
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
frontend/src/**/*.tsx: Implement TypeScript interfaces/types for all component props
Follow component composition patterns; keep components focused and single-purpose
Implement proper loading and error states in UI
Use a consistent icon set from lucide-react
Files:
frontend/src/features/auth/components/AuthOAuthProviders.tsxfrontend/src/lib/routing/AppRoutes.tsxfrontend/src/features/auth/components/AuthPasswordField.tsxfrontend/src/features/auth/page/SignInPage.tsxfrontend/src/features/auth/page/SignUpPage.tsx
frontend/src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
frontend/src/**/*.{ts,tsx}: Use TanStack Query for server state management
Use React Hook Form for form handling with Zod validation
Optimize bundle size with proper imports
Files:
frontend/src/features/auth/components/AuthOAuthProviders.tsxfrontend/src/lib/routing/AppRoutes.tsxfrontend/src/features/auth/components/AuthPasswordField.tsxfrontend/src/features/auth/page/SignInPage.tsxfrontend/src/features/auth/page/SignUpPage.tsx
frontend/src/**/[A-Z]*.tsx
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Component files must use PascalCase filenames (e.g., DataGrid.tsx)
Files:
frontend/src/features/auth/components/AuthOAuthProviders.tsxfrontend/src/lib/routing/AppRoutes.tsxfrontend/src/features/auth/components/AuthPasswordField.tsxfrontend/src/features/auth/page/SignInPage.tsxfrontend/src/features/auth/page/SignUpPage.tsx
🧬 Code graph analysis (5)
frontend/src/features/auth/components/AuthOAuthProviders.tsx (3)
shared-schemas/src/auth.schema.ts (1)
OAuthProvidersSchema(110-110)frontend/src/features/auth/components/index.ts (1)
AuthOAuthProviders(8-8)frontend/src/components/radix/Button.tsx (1)
Button(50-50)
frontend/src/lib/routing/AppRoutes.tsx (2)
frontend/src/features/auth/page/SignInPage.tsx (1)
SignInPage(17-210)frontend/src/features/auth/page/SignUpPage.tsx (1)
SignUpPage(17-222)
frontend/src/features/auth/components/AuthPasswordField.tsx (2)
frontend/src/lib/utils/utils.ts (1)
cn(19-21)frontend/src/features/auth/components/AuthPasswordStrengthIndicator.tsx (1)
AuthPasswordStrengthIndicator(44-62)
frontend/src/features/auth/page/SignInPage.tsx (6)
shared-schemas/src/auth.schema.ts (2)
OAuthProvidersSchema(110-110)OAuthConfigSchema(109-109)shared-schemas/src/auth-api.schema.ts (1)
ListOAuthConfigsResponse(201-201)frontend/src/features/auth/components/AuthFormField.tsx (1)
AuthFormField(9-20)frontend/src/features/auth/components/AuthPasswordField.tsx (1)
AuthPasswordField(19-85)frontend/src/features/auth/components/AuthSubmitButton.tsx (1)
AuthSubmitButton(10-33)frontend/src/features/auth/components/AuthOAuthProviders.tsx (1)
AuthOAuthProviders(46-149)
frontend/src/features/auth/page/SignUpPage.tsx (6)
shared-schemas/src/auth.schema.ts (2)
OAuthProvidersSchema(110-110)OAuthConfigSchema(109-109)shared-schemas/src/auth-api.schema.ts (1)
ListOAuthConfigsResponse(201-201)frontend/src/features/auth/components/AuthFormField.tsx (1)
AuthFormField(9-20)frontend/src/features/auth/components/AuthPasswordField.tsx (1)
AuthPasswordField(19-85)frontend/src/features/auth/components/AuthSubmitButton.tsx (1)
AuthSubmitButton(10-33)frontend/src/features/auth/components/AuthOAuthProviders.tsx (1)
AuthOAuthProviders(46-149)
🪛 GitHub Actions: Lint and Format Check
frontend/src/features/auth/components/AuthPasswordField.tsx
[error] 54-54: eslint: Promise-returning function provided to attribute where a void return was expected (@typescript-eslint/no-misused-promises).
🪛 GitHub Check: lint-and-format
frontend/src/features/auth/components/AuthPasswordField.tsx
[failure] 54-54:
Promise-returning function provided to attribute where a void return was expected
frontend/src/features/auth/page/SignUpPage.tsx
[failure] 19-19:
'navigate' is assigned a value but never used. Allowed unused vars must match /^_/u
🔇 Additional comments (7)
frontend/src/index.css (1)
1-1: Clarify intent of unused--fontFamilyManropevariable.The CSS variable is defined on line 63 but is not imported from any source and is not used by any component in the codebase. Verify whether this is:
Needed for the auth UI: If yes, add Manrope to the Google Fonts import on line 1, and update the auth components to use
font-family: var(--fontFamilyManrope);Dead code: If not needed yet, remove line 63 to keep the codebase clean.
Without component usage, the missing import alone is not causing a visual issue, but the incomplete variable suggests unfinished work.
frontend/src/features/auth/components/AuthPasswordField.tsx (5)
1-8: LGTM!Imports are well-organized and follow the coding guidelines. The component uses the consistent icon set from lucide-react and proper ES module syntax.
9-17: LGTM!The interface definition properly extends HTML input attributes and follows TypeScript/React best practices. The optional properties provide good flexibility for different use cases.
19-35: LGTM!The component signature and state management follow React best practices. The use of
useIdensures stable, accessible IDs, and the state variables appropriately manage local UI concerns.
70-78: LGTM!The password visibility toggle is well-implemented with proper accessibility attributes (
aria-labelandaria-pressed). The use oftype="button"correctly prevents form submission, and the icons from lucide-react are consistent with the project's design system.
80-82: LGTM!The conditional rendering and type conversion for the strength indicator are appropriately handled. The defensive
String(value || '')ensures a valid string is passed to theAuthPasswordStrengthIndicatorcomponent.frontend/src/features/auth/components/AuthOAuthProviders.tsx (1)
130-144: Nice a11y improvement with aria-label on icon buttonsGood addition; keeps the control accessible even in icon‑only mode.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
frontend/src/features/auth/helpers.tsx (1)
43-43: Simplify redundant dark mode color declaration.Since Discord uses the same color in both light and dark modes,
dark:text-[#5765F2]is redundant. The same applies to LinkedIn (line 50).Apply this diff:
- icon: <Discord className="w-6 h-6 text-[#5765F2] dark:text-[#5765F2]" />, + icon: <Discord className="w-6 h-6 text-[#5765F2]" />,Similarly for LinkedIn:
- icon: <LinkedIn className="w-6 h-6 text-[#0A66C2] dark:text-[#0A66C2]" />, + icon: <LinkedIn className="w-6 h-6 text-[#0A66C2]" />,
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
frontend/src/features/auth/helpers.tsx(1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.{ts,tsx}: Use TypeScript for all code files
Use ES modules (import/export syntax)
Prefer descriptive, unabbreviated variable and function names
Implement proper error handling with try-catch blocks and logging where appropriate
Use single quotes for strings
Include semicolons at the end of statements
Use arrow functions for callbacks and inline functions
Prefer const over let; avoid var
Use template literals for string interpolation
Maintain 2-space indentation
Format code with the repository Prettier configuration
Variables, parameters, properties, and functions must use camelCase
Constants and enum members must use UPPER_CASE
Include JSDoc comments for complex functions
Files:
frontend/src/features/auth/helpers.tsx
frontend/src/**/*.{tsx,ts}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
frontend/src/**/*.{tsx,ts}: Use functional React components with hooks exclusively
Use Radix UI primitives for accessibility
Optimize React component re-renders
Files:
frontend/src/features/auth/helpers.tsx
frontend/src/**/*.tsx
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
frontend/src/**/*.tsx: Implement TypeScript interfaces/types for all component props
Follow component composition patterns; keep components focused and single-purpose
Implement proper loading and error states in UI
Use a consistent icon set from lucide-react
Files:
frontend/src/features/auth/helpers.tsx
frontend/src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
frontend/src/**/*.{ts,tsx}: Use TanStack Query for server state management
Use React Hook Form for form handling with Zod validation
Optimize bundle size with proper imports
Files:
frontend/src/features/auth/helpers.tsx
**/*.{tsx,ts}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
React components and TypeScript types/interfaces must use PascalCase
Files:
frontend/src/features/auth/helpers.tsx
🔇 Additional comments (1)
frontend/src/features/auth/helpers.tsx (1)
36-36: Verify dark mode visibility for Microsoft icon.The
dark:text-whiteclass was removed from the Microsoft icon, while GitHub (line 29) retains it. Ensure the Microsoft SVG has sufficient contrast in dark mode without explicit color overrides.
There was a problem hiding this comment.
Actionable comments posted: 7
♻️ Duplicate comments (8)
frontend/src/features/auth/page/SignUpPage.tsx (4)
69-72: Defensive error parsing to avoid masking real errors.- if (!response.ok) { - const errorData = await response.json(); - throw new Error((errorData as { message?: string }).message || 'Sign up failed'); - } + if (!response.ok) { + const text = await response.text().catch(() => ''); + let message = 'Sign up failed'; + try { message = (JSON.parse(text) as { message?: string }).message ?? message; } catch {} + throw new Error(message); + } ``` <!-- review_comment_end --> --- `101-105`: **Normalize redirect_uri to absolute; handle malformed/relative values.** ```diff - const finalRedirectUri = redirectUrl || window.location.origin; + const finalRedirectUri = (() => { + try { + return redirectUrl + ? new URL(redirectUrl, window.location.origin).toString() + : window.location.origin; + } catch { + return window.location.origin; + } + })();This prevents backend rejections from relative/malformed URIs.
109-114: Defensive error parsing (OAuth init).- if (!response.ok) { - const errorData = await response.json(); - throw new Error( - (errorData as { message?: string }).message || `${provider} OAuth initialization failed` - ); - } + if (!response.ok) { + const text = await response.text().catch(() => ''); + let message = `${provider} OAuth initialization failed`; + try { message = (JSON.parse(text) as { message?: string }).message ?? message; } catch {} + throw new Error(message); + } ``` <!-- review_comment_end --> --- `76-88`: **Open redirect still possible; restrict redirects to same-origin (token in hash).** Using the hash reduces leakage, but redirecting to arbitrary origins remains risky. Restrict to same-origin or an allowlist; fall back to a safe route. ```diff - if (redirectUrl) { - try { - const finalUrl = new URL(redirectUrl, window.location.origin); - finalUrl.hash = `access_token=${encodeURIComponent(accessToken)}`; - window.location.assign(finalUrl.toString()); - } catch { - // Invalid redirect; default to dashboard - window.location.assign('/dashboard'); - } - } else { - window.location.assign('/dashboard'); - } + if (redirectUrl) { + try { + const url = new URL(redirectUrl, window.location.origin); + const sameOrigin = url.origin === window.location.origin; + if (sameOrigin) { + url.hash = `access_token=${encodeURIComponent(accessToken)}`; + window.location.assign(url.toString()); + } else { + window.location.assign('/dashboard'); + } + } catch { + window.location.assign('/dashboard'); + } + } else { + window.location.assign('/dashboard'); + }Backend should enforce an allowlist and prefer code/PKCE or HttpOnly cookie issuance over passing access tokens via front-end redirects.
frontend/src/features/auth/page/SignInPage.tsx (4)
69-72: Defensive error parsing to avoid masking real errors.- if (!response.ok) { - const errorData = await response.json(); - throw new Error((errorData as { message?: string }).message || 'Sign in failed'); - } + if (!response.ok) { + const text = await response.text().catch(() => ''); + let message = 'Sign in failed'; + try { message = (JSON.parse(text) as { message?: string }).message ?? message; } catch {} + throw new Error(message); + } ``` <!-- review_comment_end --> --- `101-105`: **Normalize redirect_uri to absolute; handle malformed/relative values.** ```diff - const finalRedirectUri = redirectUrl || window.location.origin; + const finalRedirectUri = (() => { + try { + return redirectUrl + ? new URL(redirectUrl, window.location.origin).toString() + : window.location.origin; + } catch { + return window.location.origin; + } + })();Prevents backend rejects on relative URIs and sanitizes malformed inputs.
109-114: Defensive error parsing (OAuth init).- if (!response.ok) { - const errorData = await response.json(); - throw new Error( - (errorData as { message?: string }).message || `${provider} OAuth initialization failed` - ); - } + if (!response.ok) { + const text = await response.text().catch(() => ''); + let message = `${provider} OAuth initialization failed`; + try { message = (JSON.parse(text) as { message?: string }).message ?? message; } catch {} + throw new Error(message); + } ``` <!-- review_comment_end --> --- `76-88`: **Open redirect still possible; restrict redirects to same-origin (token in hash).** ```diff - if (redirectUrl) { - try { - const finalUrl = new URL(redirectUrl, window.location.origin); - finalUrl.hash = `access_token=${encodeURIComponent(accessToken)}`; - window.location.assign(finalUrl.toString()); - } catch { - // Invalid redirect; default to dashboard - window.location.assign('/dashboard'); - } - } else { - window.location.assign('/dashboard'); - } + if (redirectUrl) { + try { + const url = new URL(redirectUrl, window.location.origin); + const sameOrigin = url.origin === window.location.origin; + if (sameOrigin) { + url.hash = `access_token=${encodeURIComponent(accessToken)}`; + window.location.assign(url.toString()); + } else { + window.location.assign('/dashboard'); + } + } catch { + window.location.assign('/dashboard'); + } + } else { + window.location.assign('/dashboard'); + }Enforce allowlists and prefer server-set HttpOnly cookies or code exchange.
🧹 Nitpick comments (1)
frontend/src/lib/utils/validation-schemas.ts (1)
126-136: Optional: align strongPasswordSchema messaging and escape class consistently.Minor copy tweaks; current regex is fine. No functional change required.
- .regex(/[A-Z]/, 'At least 1 Uppercase letter') - .regex(/\d/, 'At least 1 Number') - .regex(/[!@#$%^&*()_+\-=[\]{};\\|,.<>/?]/, 'Special character (e.g. !?<>@#$%)'); + .regex(/[A-Z]/, 'At least 1 uppercase letter') + .regex(/\d/, 'At least 1 number') + .regex(/[!@#$%^&*()_+\-=[\]{};\\|,.<>/?]/, 'At least 1 special character (e.g., !?<>@#$%)'); ``` <!-- review_comment_end --> </blockquote></details> </blockquote></details> <details> <summary>📜 Review details</summary> **Configuration used**: CodeRabbit UI **Review profile**: CHILL **Plan**: Pro <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between a25263a4b194bce637bbe0feab9684aba7a6656d and 55cf745382a5a824fe8c8e918a76e128ef148956. </details> <details> <summary>📒 Files selected for processing (6)</summary> * `frontend/src/features/auth/components/AuthPasswordField.tsx` (1 hunks) * `frontend/src/features/auth/components/AuthPasswordStrengthIndicator.tsx` (1 hunks) * `frontend/src/features/auth/page/SignInPage.tsx` (1 hunks) * `frontend/src/features/auth/page/SignUpPage.tsx` (1 hunks) * `frontend/src/lib/routing/AppRoutes.tsx` (2 hunks) * `frontend/src/lib/utils/validation-schemas.ts` (1 hunks) </details> <details> <summary>🚧 Files skipped from review as they are similar to previous changes (3)</summary> * frontend/src/lib/routing/AppRoutes.tsx * frontend/src/features/auth/components/AuthPasswordField.tsx * frontend/src/features/auth/components/AuthPasswordStrengthIndicator.tsx </details> <details> <summary>🧰 Additional context used</summary> <details> <summary>📓 Path-based instructions (7)</summary> <details> <summary>**/*.{ts,tsx}</summary> **📄 CodeRabbit inference engine (.github/copilot-instructions.md)** > `**/*.{ts,tsx}`: Use TypeScript for all code files > Use ES modules (import/export syntax) > Prefer descriptive, unabbreviated variable and function names > Implement proper error handling with try-catch blocks and logging where appropriate > Use single quotes for strings > Include semicolons at the end of statements > Use arrow functions for callbacks and inline functions > Prefer const over let; avoid var > Use template literals for string interpolation > Maintain 2-space indentation > Format code with the repository Prettier configuration > Variables, parameters, properties, and functions must use camelCase > Constants and enum members must use UPPER_CASE > Include JSDoc comments for complex functions Files: - `frontend/src/features/auth/page/SignUpPage.tsx` - `frontend/src/features/auth/page/SignInPage.tsx` - `frontend/src/lib/utils/validation-schemas.ts` </details> <details> <summary>frontend/src/**/*.{tsx,ts}</summary> **📄 CodeRabbit inference engine (.github/copilot-instructions.md)** > `frontend/src/**/*.{tsx,ts}`: Use functional React components with hooks exclusively > Use Radix UI primitives for accessibility > Optimize React component re-renders Files: - `frontend/src/features/auth/page/SignUpPage.tsx` - `frontend/src/features/auth/page/SignInPage.tsx` - `frontend/src/lib/utils/validation-schemas.ts` </details> <details> <summary>frontend/src/**/*.tsx</summary> **📄 CodeRabbit inference engine (.github/copilot-instructions.md)** > `frontend/src/**/*.tsx`: Implement TypeScript interfaces/types for all component props > Follow component composition patterns; keep components focused and single-purpose > Implement proper loading and error states in UI > Use a consistent icon set from lucide-react Files: - `frontend/src/features/auth/page/SignUpPage.tsx` - `frontend/src/features/auth/page/SignInPage.tsx` </details> <details> <summary>frontend/src/**/*.{ts,tsx}</summary> **📄 CodeRabbit inference engine (.github/copilot-instructions.md)** > `frontend/src/**/*.{ts,tsx}`: Use TanStack Query for server state management > Use React Hook Form for form handling with Zod validation > Optimize bundle size with proper imports Files: - `frontend/src/features/auth/page/SignUpPage.tsx` - `frontend/src/features/auth/page/SignInPage.tsx` - `frontend/src/lib/utils/validation-schemas.ts` </details> <details> <summary>**/*.{tsx,ts}</summary> **📄 CodeRabbit inference engine (.github/copilot-instructions.md)** > React components and TypeScript types/interfaces must use PascalCase Files: - `frontend/src/features/auth/page/SignUpPage.tsx` - `frontend/src/features/auth/page/SignInPage.tsx` - `frontend/src/lib/utils/validation-schemas.ts` </details> <details> <summary>frontend/src/**/[A-Z]*.tsx</summary> **📄 CodeRabbit inference engine (.github/copilot-instructions.md)** > Component files must use PascalCase filenames (e.g., DataGrid.tsx) Files: - `frontend/src/features/auth/page/SignUpPage.tsx` - `frontend/src/features/auth/page/SignInPage.tsx` </details> <details> <summary>**/[a-z][a-z0-9-]*.ts</summary> **📄 CodeRabbit inference engine (.github/copilot-instructions.md)** > Utility files should use kebab-case or camelCase (kebab-case validated here) Files: - `frontend/src/lib/utils/validation-schemas.ts` </details> </details><details> <summary>🧠 Learnings (1)</summary> <details> <summary>📚 Learning: 2025-10-15T18:18:47.519Z</summary>Learnt from: CR
PR: InsForge/InsForge#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-15T18:18:47.519Z
Learning: Applies to backend/src/**/*.{ts,tsx} : Use Zod schemas for request/response validation**Applied to files:** - `frontend/src/lib/utils/validation-schemas.ts` </details> </details><details> <summary>🧬 Code graph analysis (2)</summary> <details> <summary>frontend/src/features/auth/page/SignUpPage.tsx (7)</summary><blockquote> <details> <summary>shared-schemas/src/auth.schema.ts (2)</summary> * `OAuthProvidersSchema` (110-110) * `OAuthConfigSchema` (109-109) </details> <details> <summary>shared-schemas/src/auth-api.schema.ts (1)</summary> * `ListOAuthConfigsResponse` (201-201) </details> <details> <summary>frontend/src/lib/utils/validation-schemas.ts (1)</summary> * `signUpFormSchema` (143-146) </details> <details> <summary>frontend/src/features/auth/components/AuthFormField.tsx (1)</summary> * `AuthFormField` (9-20) </details> <details> <summary>frontend/src/features/auth/components/AuthPasswordField.tsx (1)</summary> * `AuthPasswordField` (19-87) </details> <details> <summary>frontend/src/features/auth/components/AuthSubmitButton.tsx (1)</summary> * `AuthSubmitButton` (10-33) </details> <details> <summary>frontend/src/features/auth/components/AuthOAuthProviders.tsx (1)</summary> * `AuthOAuthProviders` (46-149) </details> </blockquote></details> <details> <summary>frontend/src/features/auth/page/SignInPage.tsx (7)</summary><blockquote> <details> <summary>shared-schemas/src/auth.schema.ts (2)</summary> * `OAuthProvidersSchema` (110-110) * `OAuthConfigSchema` (109-109) </details> <details> <summary>shared-schemas/src/auth-api.schema.ts (1)</summary> * `ListOAuthConfigsResponse` (201-201) </details> <details> <summary>frontend/src/lib/utils/validation-schemas.ts (1)</summary> * `signInFormSchema` (138-141) </details> <details> <summary>frontend/src/features/auth/components/AuthFormField.tsx (1)</summary> * `AuthFormField` (9-20) </details> <details> <summary>frontend/src/features/auth/components/AuthPasswordField.tsx (1)</summary> * `AuthPasswordField` (19-87) </details> <details> <summary>frontend/src/features/auth/components/AuthSubmitButton.tsx (1)</summary> * `AuthSubmitButton` (10-33) </details> <details> <summary>frontend/src/features/auth/components/AuthOAuthProviders.tsx (1)</summary> * `AuthOAuthProviders` (46-149) </details> </blockquote></details> </details><details> <summary>🪛 GitHub Actions: Lint and Format Check</summary> <details> <summary>frontend/src/features/auth/page/SignInPage.tsx</summary> [error] 50-50: prettier/prettier: Delete `····` </details> </details> <details> <summary>🪛 GitHub Check: lint-and-format</summary> <details> <summary>frontend/src/features/auth/page/SignUpPage.tsx</summary> [failure] 50-50: Delete `····` </details> <details> <summary>frontend/src/features/auth/page/SignInPage.tsx</summary> [failure] 50-50: Delete `····` </details> <details> <summary>frontend/src/lib/utils/validation-schemas.ts</summary> [failure] 126-126: Replace `⏎··.string()⏎··` with `.string()` </details> </details> </details> <details> <summary>⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)</summary> * GitHub Check: E2E Tests * GitHub Check: CI Pre-merge Check </details> <details> <summary>🔇 Additional comments (1)</summary><blockquote> <details> <summary>frontend/src/features/auth/page/SignUpPage.tsx (1)</summary><blockquote> `50-50`: **Remove trailing spaces from line 50.** Line 50 contains 4 trailing spaces that should be removed. Run the formatter:npx prettier --write frontend/src/features/auth/page/SignUpPage.tsx
</blockquote></details> </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (6)
frontend/src/lib/utils/validation-schemas.ts (1)
118-124: Trim before validating email; current order rejects valid inputs with whitespace..email() runs before .trim(), so inputs like
' [email protected] 'fail validation. Reorder the chain so trimming happens first.Apply this diff:
export const emailSchema = z .string() + .trim() .min(1, 'Email is required') .email('Please enter a valid email address') - .toLowerCase() - .trim(); + .toLowerCase();frontend/src/features/auth/page/SignUpPage.tsx (5)
30-41: Check response.ok before parsing; consider TanStack Query.Parsing without checking
response.okcan throw on non-JSON error responses. Additionally, coding guidelines recommend TanStack Query for server state management.Apply this diff to add response.ok check:
void fetch('/api/auth/oauth/configs') - .then((res) => res.json()) + .then((res) => { + if (!res.ok) throw new Error(`Failed to fetch OAuth configs (${res.status})`); + return res.json(); + }) .then((data: ListOAuthConfigsResponse) => {Longer-term: refactor to use
useQueryfor caching and proper error handling. As per coding guidelines.
69-72: Error parsing can throw on non-JSON bodies.If the error response is HTML or plain text,
response.json()will throw and mask the actual error.Parse defensively:
if (!response.ok) { - const errorData = await response.json(); - throw new Error((errorData as { message?: string }).message || 'Sign up failed'); + const text = await response.text().catch(() => ''); + let message = 'Sign up failed'; + try { message = (JSON.parse(text) as { message?: string }).message ?? message; } catch {} + throw new Error(message); }
103-104: Validate and normalize redirect_uri to ensure absolute URL.OAuth providers typically require absolute redirect URIs. The current code uses
redirectUrldirectly if provided, which might be a relative path.Apply this diff:
- const finalRedirectUri = redirectUrl || window.location.origin; + const finalRedirectUri = (() => { + try { + return redirectUrl ? new URL(redirectUrl, window.location.origin).toString() : window.location.origin; + } catch { + return window.location.origin; + } + })();
109-114: Error parsing can throw on non-JSON bodies.Same issue as in handleSubmit:
response.json()on error responses can throw if the body isn't valid JSON.Apply defensive parsing:
if (!response.ok) { - const errorData = await response.json(); - throw new Error( - (errorData as { message?: string }).message || `${provider} OAuth initialization failed` - ); + const text = await response.text().catch(() => ''); + let message = `${provider} OAuth initialization failed`; + try { message = (JSON.parse(text) as { message?: string }).message ?? message; } catch {} + throw new Error(message); }
127-127: Fix Tailwind class typo: use bg-gradient-to-br.
bg-linear-to-bris not a valid Tailwind utility class. Usebg-gradient-to-brinstead.Apply this diff:
- <div className="min-h-screen flex items-center justify-center bg-linear-to-br from-gray-50 to-gray-100 dark:from-neutral-900 dark:to-neutral-800"> + <div className="min-h-screen flex items-center justify-center bg-gradient-to-br from-gray-50 to-gray-100 dark:from-neutral-900 dark:to-neutral-800">
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
frontend/src/features/auth/page/SignInPage.tsx(1 hunks)frontend/src/features/auth/page/SignUpPage.tsx(1 hunks)frontend/src/lib/utils/validation-schemas.ts(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- frontend/src/features/auth/page/SignInPage.tsx
🧰 Additional context used
📓 Path-based instructions (7)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.{ts,tsx}: Use TypeScript for all code files
Use ES modules (import/export syntax)
Prefer descriptive, unabbreviated variable and function names
Implement proper error handling with try-catch blocks and logging where appropriate
Use single quotes for strings
Include semicolons at the end of statements
Use arrow functions for callbacks and inline functions
Prefer const over let; avoid var
Use template literals for string interpolation
Maintain 2-space indentation
Format code with the repository Prettier configuration
Variables, parameters, properties, and functions must use camelCase
Constants and enum members must use UPPER_CASE
Include JSDoc comments for complex functions
Files:
frontend/src/features/auth/page/SignUpPage.tsxfrontend/src/lib/utils/validation-schemas.ts
frontend/src/**/*.{tsx,ts}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
frontend/src/**/*.{tsx,ts}: Use functional React components with hooks exclusively
Use Radix UI primitives for accessibility
Optimize React component re-renders
Files:
frontend/src/features/auth/page/SignUpPage.tsxfrontend/src/lib/utils/validation-schemas.ts
frontend/src/**/*.tsx
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
frontend/src/**/*.tsx: Implement TypeScript interfaces/types for all component props
Follow component composition patterns; keep components focused and single-purpose
Implement proper loading and error states in UI
Use a consistent icon set from lucide-react
Files:
frontend/src/features/auth/page/SignUpPage.tsx
frontend/src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
frontend/src/**/*.{ts,tsx}: Use TanStack Query for server state management
Use React Hook Form for form handling with Zod validation
Optimize bundle size with proper imports
Files:
frontend/src/features/auth/page/SignUpPage.tsxfrontend/src/lib/utils/validation-schemas.ts
**/*.{tsx,ts}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
React components and TypeScript types/interfaces must use PascalCase
Files:
frontend/src/features/auth/page/SignUpPage.tsxfrontend/src/lib/utils/validation-schemas.ts
frontend/src/**/[A-Z]*.tsx
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Component files must use PascalCase filenames (e.g., DataGrid.tsx)
Files:
frontend/src/features/auth/page/SignUpPage.tsx
**/[a-z][a-z0-9-]*.ts
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Utility files should use kebab-case or camelCase (kebab-case validated here)
Files:
frontend/src/lib/utils/validation-schemas.ts
🧬 Code graph analysis (1)
frontend/src/features/auth/page/SignUpPage.tsx (7)
shared-schemas/src/auth.schema.ts (2)
OAuthProvidersSchema(110-110)OAuthConfigSchema(109-109)shared-schemas/src/auth-api.schema.ts (1)
ListOAuthConfigsResponse(201-201)frontend/src/lib/utils/validation-schemas.ts (1)
signUpFormSchema(141-144)frontend/src/features/auth/components/AuthFormField.tsx (1)
AuthFormField(9-20)frontend/src/features/auth/components/AuthPasswordField.tsx (1)
AuthPasswordField(19-87)frontend/src/features/auth/components/AuthSubmitButton.tsx (1)
AuthSubmitButton(10-33)frontend/src/features/auth/components/AuthOAuthProviders.tsx (1)
AuthOAuthProviders(46-149)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: E2E Tests
- GitHub Check: CI Pre-merge Check
🔇 Additional comments (6)
frontend/src/lib/utils/validation-schemas.ts (4)
128-134: LGTM! Strong password validation properly enforced.The regex patterns correctly enforce uppercase, digit, and special character requirements. Error messages align with the AuthPasswordStrengthIndicator component.
136-139: LGTM! Clean schema composition.Properly combines emailSchema and passwordSchema for sign-in validation.
141-144: LGTM! Appropriate use of stricter validation for signup.Using strongPasswordSchema for signup ensures new users create secure passwords.
146-151: LGTM! Clean backward compatibility approach.Aliases maintain existing API while introducing clearer naming for authentication flows.
frontend/src/features/auth/page/SignUpPage.tsx (2)
1-28: LGTM! Clean imports and state setup.Component properly imports React 19 hooks and auth-related dependencies. State initialization follows best practices.
144-218: LGTM! Well-structured component with good UX patterns.The form properly uses custom validation, reusable auth components, and preserves the redirect parameter. Password strength indicator and proper autocomplete attributes enhance usability.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
docs/core-concepts/authentication/ui-components/nextjs.mdx (1)
375-497: Custom components section is comprehensive but could clarify primitive component availability.The section properly documents the transition from built-in auth to custom components, including provider configuration, pre-built components, and primitive building blocks. However, the example at lines 440-484 shows only a subset of available primitives (doesn't demonstrate AuthErrorBanner, AuthPasswordStrengthIndicator, or AuthBranding mentioned in lines 487-497), which could leave developers uncertain about when/how to use all available primitives.
Consider adding a brief note or example showing how to use the additional primitives (AuthErrorBanner, AuthPasswordStrengthIndicator, AuthBranding) not shown in the main CustomSignIn example. This would help developers understand the full palette of available components.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
docs/core-concepts/authentication/ui-components/nextjs.mdx(1 hunks)docs/docs.json(1 hunks)
🧰 Additional context used
🪛 LanguageTool
docs/core-concepts/authentication/ui-components/nextjs.mdx
[grammar] ~425-~425: Ensure spelling is correct
Context: ...fo> ### Component Props #### SignIn / SignUp tsx <SignIn afterSignInUrl="/dashboard" appearance={{ container: { background: '#f5f5f5' } }} onSuccess={(user) => console.log('Signed in:', user)} onError={(error) => console.error('Error:', error)} /> ### Build from Primitives For complete cont...
(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: E2E Tests
🔇 Additional comments (16)
docs/docs.json (1)
49-56: Navigation structure addition looks correct.The nested "UI Components" group under Authentication properly documents the new Next.js integration guide. The path reference
core-concepts/authentication/ui-components/nextjscorrectly corresponds to the MDX file atdocs/core-concepts/authentication/ui-components/nextjs.mdx(following Mintlify convention of stripping thedocs/prefix and.mdxextension).docs/core-concepts/authentication/ui-components/nextjs.mdx (15)
1-50: Clear introduction with accurate feature overview.The frontmatter, introduction, and features section provides good high-level context. The feature cards effectively communicate the value proposition, and the structure aligns well with the content provided in subsequent sections.
Verify that the "11 providers" claim (line 24-25) accurately reflects what's supported in the implementation. If the actual count differs, this should be updated to match.
53-88: Provider and API route setup examples are clear and follow Next.js conventions.Both sections properly demonstrate the app directory pattern and include explanatory notes about why each step is necessary. The environment variable usage is appropriate for public vs. private backend URLs.
Verify that:
- The
createAuthRouteHandlersfunction from@insforge/nextjs/apiincludes all three HTTP methods (POST, GET, DELETE) needed by the implementation- The
cookieNamevalue'insforge_token'is consistent with how cookies are referenced elsewhere in the authentication flow
94-158: Callback page implementation is thorough with proper guards against race conditions.The use of
isProcessingRefto prevent double-processing and the Suspense boundary are appropriate patterns. Token synchronization across localStorage, cookies (via API), and sessionStorage-based destination routing is well-coordinated.Clarify the rationale for the 100ms
setTimeouton line 130. Is this a timing requirement to ensure proper state synchronization, or is it a defensive delay? If arbitrary, consider documenting the reason or removing if not necessary.
164-176: Middleware configuration is standard and includes proper route protection setup.The public routes appropriately include the auth callback endpoint and home page, while the matcher pattern correctly excludes static assets and API routes. The
cookieNamevalue matches the API route setup, ensuring consistency.
178-202: Usage example is concise and clearly demonstrates the primary authentication flow.
203-235: Flow diagram and local development setup are well-explained.The ASCII flow effectively shows the redirect-based authentication pattern, and the separate environment variables for backend API vs. frontend auth pages make sense for local development scenarios.
Confirm that the provider automatically detects and uses
NEXT_PUBLIC_INSFORGE_FRONTEND_URLfor auth redirects when set (line 234), as documented here.
237-293: React hooks documentation shows clear examples and proper patterns.The documentation for
useAuth,useUser, anduseSessionincludes good practical examples. TheuseUserexample appropriately includes anisLoadedcheck, which is important for SSR compatibility.Verify that all methods documented in the
useAuthhook return signature (line 262) are actually implemented:signIn(),signUp(),updateUser()in addition to thesignOut()shown in examples.
295-352: Control components documentation is clear with good examples.
354-372: Server-side helpers documentation is clear and shows proper async/await pattern.Verify that
getAuthUserId()andgetAuthToken()functions are properly exported from@insforge/nextjs/middleware.
499-510: Middleware update for custom components is clear.Properly documents the required changes: adding custom route paths to publicRoutes and setting
useBuiltInAuth: false.
512-542: Customization via appearance prop and CSS is well-documented.Shows both programmatic (appearance prop) and CSS-based styling approaches, giving developers flexible customization options.
544-558: Auth callbacks section shows practical integration patterns.
560-577: TypeScript support documentation is clear.Verify that the TypeScript types
InsforgeUser,InsforgeSession, andAuthContextValueare properly exported from@insforge/nextjs.
579-605: Closing sections effectively summarize value and provide resources.
1-605: Comprehensive documentation with clear structure and practical examples.The documentation effectively explains the built-in auth flow, provides multiple setup paths (built-in vs. custom), and includes well-structured code examples following Next.js conventions. The progression from quick-start to advanced customization is logical and easy to follow.
Perform verification across these dimensions:
Component/Function existence: Verify all referenced components and functions actually exist in the
@insforge/nextjspackage:
- Components:
SignIn,SignUp,SignedIn,SignedOut,UserButton,Protect, and all auth primitives- Hooks:
useAuth,useUser,useSession- Helpers:
getAuthUserId,getAuthToken- Provider:
InsforgeProviderwithuseBuiltInAuthprop andonAuthChangecallbackAPI consistency: Verify the documented API routes and handlers match the implementation
createAuthRouteHandlersfunction signature and handlers- Callback page integration with
/api/authendpoint- Token sync action name:
'sync-token'CSS class names: Verify CSS class names used in styling section match actual implementation
insforge-btn-primary,insforge-inputI can run verification scripts if you'd like to confirm these details against the actual codebase.
c1b498d to
244a704
Compare
Summary
Introduced a built-in authentication system for cloud hosting users.
How did you test this change?
Required to use @insforge/nextjs package to build a NextJS application locally, and then connect with the insforge agent locally.
Then choose to use built-in auth components, which will redirect every sign-in and sign-up request to this built-in page.
It will redirect the user to their page after successful authentication.
Summary by CodeRabbit
New Features
UI/UX Improvements
Documentation