feat(cli): add nao reset-password command for local password recovery#583
feat(cli): add nao reset-password command for local password recovery#583Rish-it wants to merge 3 commits intogetnao:mainfrom
Conversation
🚀 Preview Deployment
Preview will be automatically removed when this PR is closed. |
There was a problem hiding this comment.
Pull request overview
Adds a local-only password recovery path by introducing a nao reset-password CLI command that updates a user’s credential password directly in the SQLite database (bypassing SMTP), along with tests and CLI registration.
Changes:
- Added
reset_passwordcommand implementation (DB path resolution, password validation, scrypt hashing, DB updates). - Registered the new command in the CLI command registry and main app entrypoint.
- Added a comprehensive pytest suite for hashing, validation, DB path resolution, and command flows.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
cli/nao_core/commands/reset_password.py |
Implements the reset-password command logic (SQLite lookup + password update). |
cli/nao_core/commands/__init__.py |
Exports the new reset_password command. |
cli/nao_core/main.py |
Registers the new command with the cyclopts app. |
cli/tests/nao_core/commands/test_reset_password.py |
Adds unit/integration-style tests covering the new command and helpers. |
scratch/test-email.ts |
Adds an SMTP test script (appears unrelated to the PR goal). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
1 issue found across 3 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="cli/nao_core/commands/reset_password.py">
<violation number="1" location="cli/nao_core/commands/reset_password.py:142">
P2: sqlite3.connect is executed before the try/except, so connection failures bypass the new sqlite3.Error handler and raise uncaught exceptions. Move the connection into the try (and guard the finally close) to ensure DB open errors are handled gracefully.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
socallmebertille
left a comment
There was a problem hiding this comment.
Thanks for your contribution ! If you could juste rebase on main it would be great ! 👍
Adds a CLI command that directly resets a user's password in the local SQLite database, bypassing SMTP entirely. Uses scrypt hashing with identical parameters to better-auth for full compatibility. Closes getnao#574
97c4788 to
646c566
Compare
|
@socallmebertille branch has updated with latest main |
Summary
Adds
nao reset-passwordCLI command for local password recovery when SMTP is not configured (fixes #574).Local deployments without SMTP have no password reset mechanism — the "Forgot password?" link is hidden and the backend silently skips email-based reset. Users had to delete
db.sqliteto recover, losing all data.Changes:
cli/nao_core/commands/reset_password.py— New command: resolves SQLite DB, prompts for email + new password, validates strength, hashes with scrypt (matching better-auth), updatesaccount.passwordand clearsrequires_password_resetflagcli/nao_core/commands/__init__.py— Export the new commandcli/nao_core/main.py— Register with cyclopts CLIcli/tests/nao_core/commands/test_reset_password.py— 24 tests covering validation, hashing, DB path resolution, and full command flowManual Testing
Prerequisites: Have a running nao instance with at least one email/password user.
Expected output:
Test Cases to Verify
Ctrl+Cduring promptScreenshots