Skip to content

fix(admin-ui): improve login errors and add password autocomplete attributes#156

Merged
intel352 merged 3 commits intomainfrom
bugfix/admin-ui-fixes
Feb 24, 2026
Merged

fix(admin-ui): improve login errors and add password autocomplete attributes#156
intel352 merged 3 commits intomainfrom
bugfix/admin-ui-fixes

Conversation

@intel352
Copy link
Contributor

Summary

  • MEDIUM — Map API error invalid credentialsInvalid email or password in login flow
  • LOW — Add autocomplete="current-password" to sign-in password field
  • LOW — Add autocomplete="new-password" to sign-up and setup wizard password fields

Test plan

  • Enter wrong credentials on login page — verify "Invalid email or password" shows instead of raw JSON
  • Password manager should offer to fill the sign-in password field (autocomplete hint)
  • Password manager should suggest saving a new password on sign-up (new-password hint)

🤖 Generated with Claude Code

…butes

- Map 'invalid credentials' API error to 'Invalid email or password' for better UX
- Add autocomplete="current-password" to sign-in password field
- Add autocomplete="new-password" to sign-up and setup wizard password fields

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings February 24, 2026 20:19
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the login user experience by mapping technical API error messages to user-friendly text and adding HTML autocomplete attributes to password fields for better password manager integration. The changes focus on the authentication flow in the admin UI.

Changes:

  • Transform raw API credential errors (e.g., "invalid credentials", "unauthorized") to "Invalid email or password" in the login flow
  • Add autocomplete="current-password" to sign-in password fields
  • Add autocomplete="new-password" to sign-up and setup wizard password fields

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
ui/src/store/authStore.ts Added error message transformation logic in login() to map credential-related errors to a user-friendly message
ui/src/components/auth/SetupWizard.tsx Added autocomplete="new-password" attributes to both password fields in the setup wizard
ui/src/components/auth/LoginPage.tsx Added conditional autocomplete attributes to password fields based on signin/signup mode

Comment on lines +102 to +106
const raw = err instanceof Error ? err.message : 'Login failed';
const friendly = /invalid.*(cred|password|user)|unauthorized|401/i.test(raw)
? 'Invalid email or password'
: raw;
set({ isLoading: false, error: friendly });
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

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

The new error message transformation logic lacks test coverage. The existing test in authStore.test.ts at line 134 expects the raw "Invalid credentials" message, but with this change it would now receive "Invalid email or password". Consider adding test cases that verify:

  1. Various API error messages (e.g., "invalid credentials", "unauthorized", "invalid password") are correctly mapped to "Invalid email or password"
  2. Non-credential errors are passed through unchanged
  3. The regex pattern correctly matches expected error formats

Copilot uses AI. Check for mistakes.
Comment on lines +102 to +106
const raw = err instanceof Error ? err.message : 'Login failed';
const friendly = /invalid.*(cred|password|user)|unauthorized|401/i.test(raw)
? 'Invalid email or password'
: raw;
set({ isLoading: false, error: friendly });
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

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

Consider applying similar user-friendly error message transformation to the register() function for consistency. Registration errors like "email already exists" or validation failures could also benefit from clearer messaging, following the same pattern established here for login errors.

Copilot uses AI. Check for mistakes.
intel352 and others added 2 commits February 24, 2026 18:32
- Use word boundaries (\b401\b) in login error regex to prevent
  false matches on strings like "4010" or "14015"
- Add user-friendly error mapping to register() for duplicate email
  errors ("already exists", "already registered", "duplicate email")
- Fix mockFetchFailure helper to return json() for proper error parsing
- Update existing tests to expect transformed friendly messages
- Add comprehensive test coverage for login/register error transformation
  including pass-through of non-matching errors

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Use strings.EqualFold instead of manual ToLower comparison (gocritic)
- Define private contextKey type for context.WithValue to satisfy
  staticcheck SA1029, update both http_router.go and http_trigger.go
- Run go mod tidy in example/ to sync dependencies

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings February 24, 2026 23:37
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 9 changed files in this pull request and generated 5 comments.

@intel352 intel352 merged commit 3078960 into main Feb 24, 2026
18 checks passed
@intel352 intel352 deleted the bugfix/admin-ui-fixes branch February 24, 2026 23:46
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