Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion auth_backend/auth_plugins/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ async def _login(user_inp: EmailLogin) -> Session:
user_inp.password, query.user.auth_methods.hashed_password.value, query.user.auth_methods.salt.value
):
raise AuthFailed(error="Incorrect login or password")
db.session.add(user_session := UserSession(user_id=query.user.id, token=random_string()))
db.session.add(user_session := UserSession(user_id=query.user.id, token=random_string(length=settings.TOKEN_LENGTH)))
db.session.commit()
return Session(
user_id=user_session.user_id, token=user_session.token, id=user_session.id, expires=user_session.expires
Expand Down
3 changes: 2 additions & 1 deletion auth_backend/settings.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from functools import lru_cache

from pydantic import BaseSettings, PostgresDsn
from pydantic import BaseSettings, PostgresDsn, conint


class Settings(BaseSettings):
Expand All @@ -12,6 +12,7 @@ class Settings(BaseSettings):
SMTP_HOST: str = 'smtp.gmail.com'
SMTP_PORT: int = 587
ENABLED_AUTH_METHODS: list[str] | None
TOKEN_LENGTH: conint(gt=8) = 64 # type: ignore

MAX_RETRIES: int = 10
STOP_MAX_DELAY: int = 10000
Expand Down