first commit

This commit is contained in:
Joren de Graaf
2026-10-04 17:09:22 +02:00
commit 1d4407462a
140 changed files with 7893 additions and 0 deletions
+8
View File
@@ -0,0 +1,8 @@
from devices.models import Sensor
def authenticate_sensor(request):
header=request.headers.get('Authorization','')
token=header.removeprefix('Bearer ').strip() if header.startswith('Bearer ') else request.headers.get('X-Sensor-Token','')
if not token: return None
for sensor in Sensor.objects.filter(token_prefix=token[:15],is_active=True,archived_at__isnull=True):
if sensor.token_matches(token): return sensor
return None