Skip to content

Allow login with plaintext passcodes and auto-rehash to bcrypt#40

Merged
TheOneWhoBurns merged 1 commit intorental-systemfrom
claude/fix-login-session-issue-gs3nR
Feb 6, 2026
Merged

Allow login with plaintext passcodes and auto-rehash to bcrypt#40
TheOneWhoBurns merged 1 commit intorental-systemfrom
claude/fix-login-session-issue-gs3nR

Conversation

@TheOneWhoBurns
Copy link
Owner

@TheOneWhoBurns TheOneWhoBurns commented Feb 6, 2026

Summary by CodeRabbit

  • Chores
    • Implemented automatic passcode security upgrade during login. The system now detects and rehashes insecure passcodes in the background after successful authentication across all login endpoints, ensuring improved data protection without disrupting the user login experience.

Existing operators/guides had plaintext passcodes in the DB which
verifyPasscode rejected. Now plaintext is accepted and automatically
rehashed to bcrypt on successful login (fire-and-forget, all endpoints).

https://claude.ai/code/session_01Rf47gNAgM7jDstC4bvffzw
@TheOneWhoBurns TheOneWhoBurns merged commit 159439a into rental-system Feb 6, 2026
0 of 2 checks passed
@TheOneWhoBurns TheOneWhoBurns deleted the claude/fix-login-session-issue-gs3nR branch February 6, 2026 21:28
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 6, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

A plaintext passcode rehashing feature is introduced to automatically upgrade plaintext credentials to hashed versions during authentication. A new rehashIfPlaintext() function detects and hashes plaintext passcodes, and it is integrated into four authentication routes to execute post-verification.

Changes

Cohort / File(s) Summary
Core Hashing Logic
src/lib/server/auth.ts
Added rehashIfPlaintext() function to detect plaintext passcodes and hash them with database updates. Extended verifyPasscode() to recognize plaintext matches and log warnings. Added imports for operators and guides schemas.
Route Integrations
src/routes/api/admin/login/+server.ts, src/routes/api/guides/verify/+server.ts, src/routes/api/operators/verify/+server.ts, src/routes/api/shifts/start/+server.ts
Imported rehashIfPlaintext and invoked it after successful authentication/verification with non-blocking error handling to trigger passcode rehashing.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Route as Route Handler
    participant Auth as Auth Module
    participant DB as Database

    Client->>Route: Send credentials
    Route->>Auth: verifyPasscode(stored, provided)
    Auth->>Auth: Check if plaintext match
    Auth-->>Route: Return true (match found)
    Route->>Route: Clear rate limit
    Route->>Auth: rehashIfPlaintext(table, id, passcode)
    Auth->>Auth: Hash plaintext passcode
    Auth->>DB: Update operators/guides table
    DB-->>Auth: Confirmation
    Auth-->>Route: Complete
    Route-->>Client: Authentication success
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 Hops through the passcode, no longer plain,
From plaintext shadows to crypto's domain!
Each login rehashes, no second refrain,
Security's garden grows greener again. 🌱

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch claude/fix-login-session-issue-gs3nR

Comment @coderabbitai help to get the list of available commands and usage tips.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants