-
Notifications
You must be signed in to change notification settings - Fork 103
Conversation
|
Resolves #453 |
|
|
||
| const platform = os.platform() | ||
| let appDataPath | ||
| const appNames = ['Ito-dev', 'Ito-local', 'Ito-prod', 'Ito'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixing cleanup script to hit all envs
| : 'Create account'} | ||
| </button> | ||
| </p> | ||
| {(!userProvider || userProvider === 'email') && ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the page that shows when a user is already signed in and has logged out / timed out. we only show the forgot password here if they are provided via email rather than something like google or apple accounts
WalkthroughAdds a password reset flow end-to-end: a new Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (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). (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (6)
scripts/clean-app-data.js (3)
8-8: Consider making app variant list configurable or sharedHard‑coding the four app variants works, but this list could drift if new variants are added elsewhere. Consider either:
- deriving
appNamesfrom a single shared config, or- allowing optional CLI arguments to override/extend this list,
so the cleanup script stays in sync with actual deployments.
10-20: Verify Linux path casing and consider XDG_CONFIG_HOME supportOn non‑macOS/Windows platforms,
getAppDataPathuses~/.config/${appName.toLowerCase()}while other branches keep the original casing. If any existing Linux data directories were created with a different case (e.g.Ito-dev), this script will miss them. Either:
- confirm that the app’s Linux user data path is indeed lowercase and document that assumption, or
- drop
.toLowerCase()for symmetry, or- optionally check both variants when cleaning.
Additionally, you may want to honor
XDG_CONFIG_HOMEwhen set (falling back to~/.config) for more standard Linux behavior.
23-30: Add error handling aroundfs.rmSyncto avoid abrupt script failuresIf
fs.rmSynchits permissions issues or other filesystem errors, the script will currently throw and stop at the first failing app directory. Wrapping the removal in a small try/catch withconsole.errorwould make the cleanup more robust while still surfacing failures, for example:- if (fs.existsSync(appDataPath)) { - fs.rmSync(appDataPath, { recursive: true, force: true }) - console.log(`✓ Removed app data from: ${appDataPath}`) - } else { - console.log(`ℹ No app data found at: ${appDataPath}`) - } + if (fs.existsSync(appDataPath)) { + try { + fs.rmSync(appDataPath, { recursive: true, force: true }) + console.log(`✓ Removed app data from: ${appDataPath}`) + } catch (err) { + console.error(`✗ Failed to remove app data at: ${appDataPath}`, err) + } + } else { + console.log(`ℹ No app data found at: ${appDataPath}`) + }This also keeps you compliant with the “no empty catch” guideline.
server/src/services/auth0.ts (1)
8-11: Strengthen/auth0/reset-passwordhandler (typing, logging, validation).The overall flow looks solid (env guards, Auth0 call, safe JSON/text parsing), but a few hardening tweaks would help:
- Line 219: avoid introducing new
any(catch (error: any)). Preferunknownand narrow when building the message, e.g.,error instanceof Error ? error.message : 'Network error'. This keeps you aligned with the “never use any” guideline.- Consider logging the caught error via
fastify.log.errorbefore returning 500 so failures are observable from the server side, similar togetManagementToken.- Since
connectionis taken from the request body, you may want to ignore arbitrary values and/or whitelist known DB connections if this route might ever be called by anything other than your own client.Example for the catch block:
- } catch (error: any) { - reply - .status(500) - .send({ success: false, error: error?.message || 'Network error' }) - } + } catch (error: unknown) { + fastify.log.error({ error }, '[Auth0] reset-password error') + const message = + error instanceof Error ? error.message : 'Network error' + reply.status(500).send({ success: false, error: message }) + }Also applies to: 168-224
app/components/welcome/contents/SignInContent.tsx (1)
22-22: Sign-in integration with ResetPassword is solid; consider passing email through.The new
showResetPasswordstate, early return, and the conditional “Forgot password” link for email/no-provider cases all line up well with the intended UX, and the 50/50 layout keeps the reset view visually consistent with the main sign-in pane.As a small cleanup, you could pass the known
userEmailinto<ResetPassword>here instead of having that component re-read fromwindow.electron?.store, e.g.:if (showResetPassword) { return ( <ResetPassword email={typeof userEmail === 'string' ? userEmail : undefined} onBack={() => setShowResetPassword(false)} /> ) }Not strictly necessary, but it would centralize where the email value comes from and simplify testing.
Also applies to: 124-124, 417-419, 424-425, 463-490, 495-496
app/components/welcome/contents/ResetPassword.tsx (1)
1-225: ResetPassword behavior matches the flow; tighten types and timer lifecycle.The overall UX and wiring to
auth0-reset-passwordlook good (pre-populated email, clear “Check your inbox” state, resend throttling). A couple of implementation details are worth tightening:
- Lines 56 & 88: both handlers use
catch (e: any). Per the TypeScript guidelines, avoid newanyusage. You can switch tounknownand narrow when building the error message:- } catch (e: any) { - setError(e?.message || 'An error occurred') + } catch (e: unknown) { + const message = + e instanceof Error ? e.message : 'An error occurred' + setError(message) } finally { setIsLoading(false) }(and similarly in
handleResend).
Lines 40–52 and 74–84: the countdown logic is duplicated and each call creates its own
setIntervalthat only clears itself whensecondsreaches 0. If the component unmounts while a countdown is active (e.g., user navigates back immediately), those intervals will still run briefly and attemptsetSeconds, which is best avoided. Consider centralizing the countdown into auseRef+useEffectpair that:
- Clears any existing interval before starting a new one.
- Cleans up in the effect’s return function on unmount.
Optional UX tweak:
handleOpenEmailAppcurrently usesmailto:with no address; you could passeditableEmail(mailto:${editableEmail}) so the reset email target is prefilled in the mail client.None of these block the flow, but they’ll make the component more robust and closer to the project’s TypeScript standards. As per coding guidelines, avoiding
anyis the most important of these.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
app/components/welcome/contents/EmailLoginContent.tsx(4 hunks)app/components/welcome/contents/ResetPassword.tsx(1 hunks)app/components/welcome/contents/SignInContent.tsx(5 hunks)lib/window/ipcEvents.ts(1 hunks)scripts/clean-app-data.js(1 hunks)server/src/services/auth0.ts(2 hunks)
🧰 Additional context used
📓 Path-based instructions (12)
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (CLAUDE.md)
Always prefer console commands over log commands. Use
console.loginstead oflog.info
Files:
scripts/clean-app-data.jsapp/components/welcome/contents/ResetPassword.tsxlib/window/ipcEvents.tsapp/components/welcome/contents/EmailLoginContent.tsxserver/src/services/auth0.tsapp/components/welcome/contents/SignInContent.tsx
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/always.mdc)
Never use empty catch statements
Files:
scripts/clean-app-data.jsapp/components/welcome/contents/ResetPassword.tsxlib/window/ipcEvents.tsapp/components/welcome/contents/EmailLoginContent.tsxserver/src/services/auth0.tsapp/components/welcome/contents/SignInContent.tsx
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/code-conventions.mdc)
**/*.{ts,tsx}: Follow standard, idiomatic TypeScript coding practices for structure, naming, and types
Avoid adding comments unless they explain complex logic or non-obvious decisions; well-written, self-explanatory code is preferred
Do not add comments that merely restate what the code does
Rely on comprehensive tests to document the behavior and usage of code rather than extensive comments within the code itself
Use kebab-case when naming directories, TypeScript, and other files
**/*.{ts,tsx}: Prefer interfaces over types for object definitions
Use type for unions, intersections, and mapped types
NEVER useanyoras anytypes or coercion
Leverage TypeScript's built-in utility types
Use generics for reusable type patterns
Use PascalCase for type names and interfaces
Use camelCase for variables and functions
Use UPPER_CASE for constants
Use descriptive names with auxiliary verbs (e.g., isLoading, hasError)
Prefix interfaces for React props with 'Props' (e.g., ButtonProps)
Keep type definitions close to where they're used
Export types and interfaces from dedicated type files when shared
Co-locate component props with their components
Use explicit return types for public functions
Use arrow functions for callbacks and methods
Implement proper error handling with custom error types
Use function overloads for complex type scenarios
Prefer async/await over Promises
Prefer function declarations over function expressions
Use readonly for immutable properties
Leverage discriminated unions for type safety
Use type guards for runtime type checking
Implement proper null checking
Avoid type assertions unless necessary
Handle Promise rejections properly
Files:
app/components/welcome/contents/ResetPassword.tsxlib/window/ipcEvents.tsapp/components/welcome/contents/EmailLoginContent.tsxserver/src/services/auth0.tsapp/components/welcome/contents/SignInContent.tsx
**/*.tsx
📄 CodeRabbit inference engine (.cursor/rules/react.mdc)
**/*.tsx: Use kebab-case for files and directories
Do not use 'use client' or 'use server' statements in React components
Favor named exports for components
Ensure components are modular, reusable, and maintain a clear separation of concerns
Always split React components so there is only ever one per file
Keep logic as low as possible in React components
Implement responsive design with Tailwind CSS using a mobile-first approach
Files:
app/components/welcome/contents/ResetPassword.tsxapp/components/welcome/contents/EmailLoginContent.tsxapp/components/welcome/contents/SignInContent.tsx
app/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
Electron renderer code should be organized in the
app/directory and use React + Tailwind
Files:
app/components/welcome/contents/ResetPassword.tsxapp/components/welcome/contents/EmailLoginContent.tsxapp/components/welcome/contents/SignInContent.tsx
{app,lib}/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use Prettier with 2-space indent for code formatting across TypeScript and React files
Files:
app/components/welcome/contents/ResetPassword.tsxlib/window/ipcEvents.tsapp/components/welcome/contents/EmailLoginContent.tsxapp/components/welcome/contents/SignInContent.tsx
{app,lib,server}/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
{app,lib,server}/**/*.{ts,tsx,js,jsx}: Use ESLint to enforce code style and runbun run lintbefore submitting code
Always useconsolecommands instead of log commands (e.g.,console.loginstead oflog.info)
Files:
app/components/welcome/contents/ResetPassword.tsxlib/window/ipcEvents.tsapp/components/welcome/contents/EmailLoginContent.tsxserver/src/services/auth0.tsapp/components/welcome/contents/SignInContent.tsx
{app,lib}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
{app,lib}/**/*.{ts,tsx}: Components and classes usePascalCasenaming convention
Hooks and utility functions usecamelCasenaming convention
Files:
app/components/welcome/contents/ResetPassword.tsxlib/window/ipcEvents.tsapp/components/welcome/contents/EmailLoginContent.tsxapp/components/welcome/contents/SignInContent.tsx
{app,lib,server}/**/*.{ts,tsx,js}
📄 CodeRabbit inference engine (AGENTS.md)
Constants use
SCREAMING_SNAKE_CASEnaming convention
Files:
app/components/welcome/contents/ResetPassword.tsxlib/window/ipcEvents.tsapp/components/welcome/contents/EmailLoginContent.tsxserver/src/services/auth0.tsapp/components/welcome/contents/SignInContent.tsx
app/**/*.{tsx,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
Co-locate Tailwind styles with React components and reuse tokens via
lib/constants
Files:
app/components/welcome/contents/ResetPassword.tsxapp/components/welcome/contents/EmailLoginContent.tsxapp/components/welcome/contents/SignInContent.tsx
lib/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
Shared TypeScript modules, preload logic, and unit tests should be organized in
lib/
Files:
lib/window/ipcEvents.ts
server/**/*.{ts,js}
📄 CodeRabbit inference engine (AGENTS.md)
Backend code and database migrations should be organized in
server/using Bun
Files:
server/src/services/auth0.ts
🧬 Code graph analysis (4)
app/components/welcome/contents/ResetPassword.tsx (4)
lib/constants/store-keys.ts (1)
STORE_KEYS(3-15)app/utils/utils.ts (1)
isValidEmail(1-4)app/components/ui/button.tsx (1)
Button(59-59)app/components/ui/app-orbit-image.tsx (1)
AppOrbitImage(91-257)
lib/window/ipcEvents.ts (2)
lib/clients/itoHttpClient.ts (1)
itoHttpClient(91-91)lib/auth/config.ts (1)
Auth0Connections(13-19)
app/components/welcome/contents/EmailLoginContent.tsx (1)
app/components/welcome/contents/ResetPassword.tsx (1)
ResetPassword(12-226)
app/components/welcome/contents/SignInContent.tsx (1)
app/components/welcome/contents/ResetPassword.tsx (1)
ResetPassword(12-226)
⏰ 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). (3)
- GitHub Check: run-tests / test
- GitHub Check: Analyze (rust)
- GitHub Check: Analyze (swift)
🔇 Additional comments (2)
lib/window/ipcEvents.ts (1)
424-431: Confirm reset-password IPC is usable while logged out.The IPC wiring to
/auth0/reset-passwordlooks consistent with other Auth0 proxies, and usingAuth0Connections.databaseis correct. One thing to double‑check: ifitoHttpClient.postdefaults torequireAuth: true, this call will fail for users who are logged out (the main reset-password use case). Please verify that this route is either exempt from auth or thatitoHttpClient.postis called with options that allow unauthenticated access.app/components/welcome/contents/EmailLoginContent.tsx (1)
6-6: ResetPassword toggle in email login looks coherent.The
showResetPasswordtoggle, early return, and “Forgot password?” button wiring are clean, and seedingResetPasswordonly whenemailOkis true avoids carrying invalid input into the flow. No issues from my side here.Also applies to: 18-18, 48-56, 129-134
Tested full lifecycle by connecting auth to my local server, was able to reset password as expected