/
pa1ch
/
FitAssistant
Обзор
Документация
Войти
/
pa1ch
/
FitAssistant
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
app/models/refresh_token.py
22 строки
761 B
pa1ch
Запрос на слияние 'feat/workout-calendar' (
#1
) из feat/workout-calendar в master
01 июн 2026, 15:58
Верифицирован
01 июн 2026, 15:58
babdc59
Код
Авторство
О чём код?
from datetime import datetime from sqlalchemy import ForeignKey from sqlalchemy.orm import Mapped, mapped_column from app.models.base import Base class RefreshToken(Base): """A long-lived refresh token issued to a user session. We store only the SHA-256 hash of the token, never the token itself, so a database leak can't be replayed. Rotation revokes the old row (sets `revoked_at`) and inserts a new one on every refresh. """ __tablename__ = "refresh_tokens" user_id: Mapped[int] = mapped_column(ForeignKey("users.id", ondelete="CASCADE"), index=True) token_hash: Mapped[str] = mapped_column(index=True, unique=True) expires_at: Mapped[datetime] revoked_at: Mapped[datetime | None] = mapped_column(default=None)