mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-04-15 03:22:10 +03:00
add class method to user to retrieve all allowed cameras
This commit is contained in:
parent
375c824ea3
commit
c9578a7c02
@ -135,6 +135,18 @@ class User(Model):
|
||||
password_hash = CharField(null=False, max_length=120)
|
||||
notification_tokens = JSONField()
|
||||
|
||||
@classmethod
|
||||
def get_allowed_cameras(
|
||||
cls, role: str, roles_dict: dict[str, list[str]], all_camera_names: set[str]
|
||||
) -> list[str]:
|
||||
if role not in roles_dict:
|
||||
return [] # Invalid role grants no access
|
||||
allowed = roles_dict[role]
|
||||
if not allowed: # Empty list means all cameras
|
||||
return list(all_camera_names)
|
||||
|
||||
return [cam for cam in allowed if cam in all_camera_names]
|
||||
|
||||
|
||||
class Trigger(Model):
|
||||
camera = CharField(max_length=20)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user