Skip to content

fix: login Snackbar Shows Undefined for Invalid Credentials#1092

Open
DevipriyaS17 wants to merge 3 commits into
mainfrom
undefined
Open

fix: login Snackbar Shows Undefined for Invalid Credentials#1092
DevipriyaS17 wants to merge 3 commits into
mainfrom
undefined

Conversation

@DevipriyaS17

Copy link
Copy Markdown
Contributor

Description
This PR fixes issue #994 where the login snackbar showed Undefined when invalid username/password was submitted.

Problem
When POST /api/v1/authorize returned 401 for bad credentials, the frontend expected a message field but did not receive a clear user-facing value, which resulted in an unclear snackbar message.

Root Cause
The invalid-credentials response did not include a user-friendly message aligned with frontend expectations.

Expected behavior
When the username or password is incorrect, the snackbar should show a clear message such as Incorrect username or password.

Screenshots
incorrect

@DevipriyaS17 DevipriyaS17 requested a review from a team as a code owner June 23, 2026 05:56
@DevipriyaS17 DevipriyaS17 linked an issue Jun 23, 2026 that may be closed by this pull request
@codecov

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 43.49%. Comparing base (cc77603) to head (44dd41d).

Files with missing lines Patch % Lines
internal/controller/openapi/devices.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1092      +/-   ##
==========================================
+ Coverage   43.44%   43.49%   +0.05%     
==========================================
  Files         143      143              
  Lines       13621    13621              
==========================================
+ Hits         5917     5924       +7     
+ Misses       7143     7135       -8     
- Partials      561      562       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 addresses issue #994 by ensuring the v1 login endpoint returns a user-friendly error message when invalid credentials are submitted, preventing the UI snackbar from displaying Undefined.

Changes:

  • Update POST /api/v1/authorize invalid-credentials (401) response to include a message field with a user-friendly string.
  • Add a regression test verifying the 401 response includes both error and message.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
internal/controller/httpapi/v1/login.go Adds message to the 401 invalid-credentials JSON response.
internal/controller/httpapi/v1/login_test.go Adds a test to assert the invalid-credentials response includes the expected message.

Comment thread internal/controller/httpapi/v1/login.go Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 5 out of 5 changed files in this pull request and generated no new comments.

@DevipriyaS17 DevipriyaS17 marked this pull request as ready for review July 1, 2026 06:56
func (lr LoginRoute) handleBasicAuth(creds dto.Credentials, c *gin.Context) {
if creds.Username != lr.Config.AdminUsername || creds.Password != lr.Config.AdminPassword {
c.JSON(http.StatusUnauthorized, gin.H{errorKey: "invalid credentials"})
c.JSON(http.StatusUnauthorized, gin.H{errorKey: "invalid credentials", messageKey: "Incorrect username or password"})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
c.JSON(http.StatusUnauthorized, gin.H{errorKey: "invalid credentials", messageKey: "Incorrect username or password"})
c.JSON(http.StatusUnauthorized, gin.H{errorKey: "invalid credentials", messageKey: "Incorrect Username and/or Password!"})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Have the error message consistent with MPS

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.

Login Snackbar Shows Undefined for Invalid Credentials

4 participants