enable caldav access check
This commit is contained in:
@@ -8,6 +8,7 @@ from sqlmodel import select
|
||||
from app.model.models import Card, OneShotAccess
|
||||
from app.services.database import Session, add_and_refresh
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -98,12 +99,17 @@ def decrementOneshot(db: Session, oneshot: OneShotAccess):
|
||||
|
||||
def checkAccess(key: str, db: Session):
|
||||
try:
|
||||
current_weekday = datetime.weekday(date.today())
|
||||
current_time = datetime.now()
|
||||
card = db.exec(select(Card).where(Card.key == key)).one()
|
||||
if not card.enabled:
|
||||
logger.info("Card Inactive!")
|
||||
return False
|
||||
|
||||
if caldav_handler.is_group_active(card.group.name):
|
||||
logger.info("Access Valid!")
|
||||
return True
|
||||
|
||||
current_weekday = datetime.weekday(date.today())
|
||||
current_time = datetime.now()
|
||||
for auth in card.group.accessauths:
|
||||
logger.info(f"checking auth: {auth.name}")
|
||||
if not auth.is_active:
|
||||
|
||||
Reference in New Issue
Block a user