diff --git a/internal/handlers/auth.go b/internal/handlers/auth.go index f248639..8d6ca24 100644 --- a/internal/handlers/auth.go +++ b/internal/handlers/auth.go @@ -281,7 +281,10 @@ func (h *AuthHandler) GetProfile(c echo.Context) error { user, err := h.db.GetUser(c.Request().Context(), pgtype.UUID{Bytes: userUUID, Valid: true}) if err != nil { - return c.JSON(http.StatusNotFound, map[string]string{"error": "user not found"}) + if err == pgx.ErrNoRows { + return c.JSON(http.StatusNotFound, map[string]string{"error": "user not found"}) + } + return c.JSON(http.StatusInternalServerError, map[string]string{"error": err.Error()}) } firstName := "" @@ -652,6 +655,9 @@ func (h *AuthHandler) UpdatePassword(c echo.Context) error { // Get current user's password hash passwordHash, err := h.db.GetUserPasswordHash(c.Request().Context(), pgtype.UUID{Bytes: userUUID, Valid: true}) if err != nil { + if err == pgx.ErrNoRows { + return c.JSON(http.StatusNotFound, map[string]string{"error": "user not found"}) + } return c.JSON(http.StatusInternalServerError, map[string]string{"error": "failed to get user"}) } @@ -738,11 +744,14 @@ func (h *AuthHandler) GetScanSettings(c echo.Context) error { settings, err := h.db.GetScanSettings(c.Request().Context(), pgtype.UUID{Bytes: userUUID, Valid: true}) if err != nil { - // If no settings found, return defaults - return c.JSON(http.StatusOK, map[string]interface{}{ - "scan_frequency_minutes": 60, - "auto_scan_enabled": true, - }) + if err == pgx.ErrNoRows { + // If no settings found, return defaults + return c.JSON(http.StatusOK, map[string]interface{}{ + "scan_frequency_minutes": 60, + "auto_scan_enabled": true, + }) + } + return c.JSON(http.StatusInternalServerError, map[string]string{"error": err.Error()}) } return c.JSON(http.StatusOK, map[string]interface{}{