fix: standardize authentication error messages
Lint / Lint (push) Successful in 20s
Tests / Go backend (push) Successful in 39s
Tests / Dashboard checks (push) Successful in 38s
Docker / Docker Build & Push (push) Successful in 2m49s

- Capitalize messages and add terminal punctuation
- Clarify reset-code and authenticator-code errors
This commit is contained in:
Gabriel20xx committed 2026-08-25 19:20:18 +00:00
1 parent c4b40a9c36
commit a37acb1133
1 file changed
+6 -6
+6 -6
View File
@@ -238,7 +238,7 @@ func (a *AuthService) handleResetConfirm(w http.ResponseWriter, r *http.Request)
return
}
if !a.reset.Confirm(request.Code) {
writeJSONError(w, http.StatusUnauthorized, "Invalid or expired code")
writeJSONError(w, http.StatusUnauthorized, "Invalid or expired reset code.")
return
}
if err := a.db.deleteAllUsers(r.Context()); err != nil {
@@ -331,7 +331,7 @@ func (a *AuthService) handleLogin(w http.ResponseWriter, r *http.Request) {
return
}
if user.TOTPEnabled && !sharedauth.VerifyTOTP(user.TOTPSecret, request.TotpToken, time.Now()) {
writeJSONError(w, http.StatusUnauthorized, "two-factor authentication code required")
writeJSONError(w, http.StatusUnauthorized, "Two-factor authentication code required.")
return
}
if err := a.startSession(r.Context(), w, user.ID); err != nil {
@@ -382,7 +382,7 @@ func (a *AuthService) handleTOTPEnable(w http.ResponseWriter, r *http.Request, u
}
secret, _, err := a.db.getTOTPState(r.Context(), user.ID)
if err != nil || !sharedauth.VerifyTOTP(secret, request.Token, time.Now()) {
writeJSONError(w, http.StatusUnauthorized, "invalid two-factor authentication code")
writeJSONError(w, http.StatusUnauthorized, "Invalid authenticator code.")
return
}
if err := a.db.enableTOTP(r.Context(), user.ID); err != nil {
@@ -400,7 +400,7 @@ func (a *AuthService) handleTOTPDisable(w http.ResponseWriter, r *http.Request,
}
secret, enabled, err := a.db.getTOTPState(r.Context(), user.ID)
if err != nil || !enabled || !sharedauth.VerifyTOTP(secret, request.Token, time.Now()) {
writeJSONError(w, http.StatusUnauthorized, "invalid two-factor authentication code")
writeJSONError(w, http.StatusUnauthorized, "Invalid authenticator code.")
return
}
if err := a.db.disableTOTP(r.Context(), user.ID); err != nil {
@@ -579,7 +579,7 @@ func (a *AuthService) handleUsers(w http.ResponseWriter, r *http.Request, actor
}
created, err := a.db.createManagedUser(r.Context(), username, email, string(hash), role)
if err != nil {
writeJSONError(w, http.StatusConflict, "Username or email is already in use")
writeJSONError(w, http.StatusConflict, "Username or email is already in use.")
return
}
writeJSON(w, http.StatusCreated, managedUserView(*created))
@@ -652,7 +652,7 @@ func (a *AuthService) handleUser(w http.ResponseWriter, r *http.Request, actor *
role = string(sharedauth.NormalizeRole(*request.Role))
}
if err := a.db.updateManagedUser(r.Context(), id, username, email, passwordHash, role); err != nil {
writeJSONError(w, http.StatusConflict, "Username or email is already in use")
writeJSONError(w, http.StatusConflict, "Username or email is already in use.")
return
}
writeJSON(w, http.StatusOK, map[string]bool{"ok": true})