Skip to content

feat: add remember password function#1317

Open
bittoby wants to merge 10 commits intoeigent-ai:mainfrom
bittoby:feat/remember-me-login
Open

feat: add remember password function#1317
bittoby wants to merge 10 commits intoeigent-ai:mainfrom
bittoby:feat/remember-me-login

Conversation

@bittoby
Copy link
Contributor

@bittoby bittoby commented Feb 20, 2026

Related Issue

Closes #1316

Description

Adds secure "Remember Me" credential storage for the login page using Electron's built-in safeStorage API, which encrypts credentials via OS-level keychain (macOS Keychain, Windows DPAPI, Linux Secret Service). No new dependencies required.

What it does:

  • Encrypts and persists email/password credentials locally at ~/.eigent/saved_credentials.enc (file permissions 0o600)
  • Auto-fills the most recently used account on login page load
  • Shows a saved accounts dropdown (with masked emails) when focusing the email field, allowing quick account switching
  • Each saved account can be individually removed from the dropdown
  • "Remember Me" checkbox controls whether credentials are saved or cleared after successful login

Files changed:

  • electron/main/index.ts — 3 IPC handlers (credentials-save, credentials-load, credentials-remove) using safeStorage.encryptString() / decryptString()
  • electron/preload/index.ts — Exposed credential APIs to renderer via electronAPI bridge
  • src/types/electron.d.ts — TypeScript declarations for new credential methods
  • src/pages/Login.tsx — Remember Me checkbox, saved accounts dropdown with outside-click dismiss, auto-fill on mount
  • 11 i18n locale files — Added remember-me, saved-accounts, remove-account keys (en, zh-Hans, zh-Hant, ja, ko, de, fr, es, it, ru, ar)

Testing Evidence (REQUIRED)

login.mp4
  • I have included human-verified testing evidence in this PR.
  • This PR includes frontend/UI changes, and I attached screenshot(s) or screen recording(s).
  • No frontend/UI changes in this PR.

What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Contribution Guidelines Acknowledgement

@bittoby bittoby marked this pull request as draft February 20, 2026 10:11
@bittoby bittoby marked this pull request as ready for review February 20, 2026 10:45
@bittoby
Copy link
Contributor Author

bittoby commented Feb 20, 2026

@Pakchoioioi @Wendong-Fan Could you please review the PR?
thank you

@Wendong-Fan
Copy link
Contributor

thanks @bittoby ! could @4pmtong and @fengju0213 help reviewing this feature?

@bittoby
Copy link
Contributor Author

bittoby commented Feb 25, 2026

@Wendong-Fan @4pmtong @fengju0213 I'd really appreciate your feedback!
thank you

Copy link
Collaborator

@nitpicker55555 nitpicker55555 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR has several serious issues. A pure function is wrapped in useMemo even though it does not depend on any state and should be defined outside the component. Returning a function from useMemo with an empty dependency array is meaningless and looks like AI-driven over-optimization. The implementation stores plaintext passwords instead of persisting the existing auth token via setAuth, which indicates the current authentication flow was not properly reviewed. There is also a redundant map in credentials-load where the input and output shapes are identical, making it unnecessary code. In addition, credentialsLoad() has no error handling and lacks a catch on the promise.

Considering the extent of these problems, iterating through review cycles would likely cost more effort than rewriting it. I suggest closing this PR and submitting a clean one instead. @Wendong-Fan @4pmtong

@bittoby
Copy link
Contributor Author

bittoby commented Feb 27, 2026

@nitpicker55555 please don't close this PR. I will update in this PR

@bittoby
Copy link
Contributor Author

bittoby commented Feb 27, 2026

@nitpicker55555 I updated to follow your feedback.

What i have changed:

  • Password storage removed - the implementation now persists the auth token (token, username, user_id) returned by the login API, not the user's password. Selecting a saved account calls setAuth directly and navigates without re-entering credentials.
  • useMemo misuse removed - maskEmail is now a plain module-level function outside the component.
  • Redundant .map() removed - credentials-load returns the accounts array directly.
  • Error handling added - credentialsLoad is now wrapped in try/catch.
  • Runtime bug fixed - the account filter was rejecting all saved entries because user_id from the API is a string at runtime, not a number. The filter now only validates email and token, which is sufficient.

@bittoby bittoby marked this pull request as draft February 27, 2026 16:30
@bittoby bittoby marked this pull request as ready for review February 27, 2026 16:42
@fengju0213
Copy link
Collaborator

@nitpicker55555 I updated to follow your feedback.

What i have changed:

  • Password storage removed - the implementation now persists the auth token (token, username, user_id) returned by the login API, not the user's password. Selecting a saved account calls setAuth directly and navigates without re-entering credentials.
  • useMemo misuse removed - maskEmail is now a plain module-level function outside the component.
  • Redundant .map() removed - credentials-load returns the accounts array directly.
  • Error handling added - credentialsLoad is now wrapped in try/catch.
  • Runtime bug fixed - the account filter was rejecting all saved entries because user_id from the API is a string at runtime, not a number. The filter now only validates email and token, which is sufficient.

thanks @bittoby will review it asap

Copy link
Collaborator

@fengju0213 fengju0213 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @bittoby overall its good,I'm wondering if automatic autofill is sufficient, and automatic login isn't necessary, because there might be other operations on this login page later, such as changing the password, etc.
cc @Pakchoioioi

@bittoby bittoby force-pushed the feat/remember-me-login branch from 2ca5bc1 to 4336b3b Compare March 3, 2026 15:31
user_id: number
) => {
try {
const accounts = readSavedAccounts();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we change readSavedAccounts, writeSavedAccounts etc to async? such as fs.promises so that we do not block the ipc main thread

email: account.email,
user_id: account.user_id,
});
setModelType('cloud');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a todo that we should need to avoid set this as cloud by default in the future

onClick={() => handleSelectAccount(account)}
>
<span className="text-label-md text-text-primary">
{maskEmail(account.email)}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to mask in this way? maybe we should remove the masking

state={errors.email ? 'error' : undefined}
note={errors.email}
onEnter={handleLogin}
onFocus={() => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now there is a problem that for example if we save an email such as abc@gmail.com
then in the email if I typed new one such as def@gmail.com the dropdown including the abc@gmail.com is still available.
We should have that if the prefix does not match with any saved emails then we should not show the dropdown

@bittoby
Copy link
Contributor Author

bittoby commented Mar 4, 2026

Thanks for your feedback @bytecii . I will check again

@bittoby
Copy link
Contributor Author

bittoby commented Mar 4, 2026

@bytecii I have updated all to follow your feedback. please review again.
thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Support "Remember Me" / Auto-fill for Email & Password Login

5 participants