setting, session and profile
This commit is contained in:
parent
48eea5d201
commit
4a563f4f34
31 changed files with 1797 additions and 159 deletions
|
|
@ -7,8 +7,7 @@ from sqlalchemy.ext.asyncio import AsyncSession
|
|||
|
||||
from app.models import OrgSecuritySettings
|
||||
from app.schemas import OrgSecuritySettingsRead, OrgSecuritySettingsUpdate
|
||||
|
||||
ALLOWED_SESSION_TIMEOUTS = {15, 30, 60, 120, 480, 1440}
|
||||
from app.services.session_policy import validate_session_timeout_minutes
|
||||
|
||||
|
||||
async def get_or_create_security_settings(
|
||||
|
|
@ -43,12 +42,7 @@ async def update_security_settings(
|
|||
settings = await get_or_create_security_settings(session, company_domain)
|
||||
updates = payload.model_dump(exclude_unset=True)
|
||||
if "session_timeout_minutes" in updates:
|
||||
timeout = updates["session_timeout_minutes"]
|
||||
if timeout not in ALLOWED_SESSION_TIMEOUTS:
|
||||
raise ValueError(
|
||||
"Session timeout must be one of: "
|
||||
+ ", ".join(str(value) for value in sorted(ALLOWED_SESSION_TIMEOUTS))
|
||||
)
|
||||
validate_session_timeout_minutes(updates["session_timeout_minutes"])
|
||||
for field, value in updates.items():
|
||||
setattr(settings, field, value)
|
||||
await session.flush()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue