From c9ec222945f24af2456c6379b22b954917f31e5c Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Fri, 30 Jan 2026 21:47:30 -0500 Subject: [PATCH] feat: add ValidateDeviceToken method to device auth middleware Add device token validation method for WebSocket authentication: - Validates device auth tokens against database - Returns device information for valid tokens - Used by WebSocket handler for device authentication This enables devices to authenticate WebSocket connections using their bearer tokens. --- internal/middleware/device_auth.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/middleware/device_auth.go b/internal/middleware/device_auth.go index c46e4b3..5c6daed 100644 --- a/internal/middleware/device_auth.go +++ b/internal/middleware/device_auth.go @@ -2,6 +2,7 @@ package middleware import ( "bookmann/internal/database" + "context" "net/http" "strings" @@ -173,3 +174,7 @@ func (m *DeviceAuthMiddleware) UpdateLastSeen(next echo.HandlerFunc) echo.Handle return err } } + +func (m *DeviceAuthMiddleware) ValidateDeviceToken(token string) (database.Devices, error) { + return m.db.GetDeviceByAuthToken(context.Background(), token) +}