초기 커밋
This commit is contained in:
39
app/models/mariadb/auth.py
Normal file
39
app/models/mariadb/auth.py
Normal file
@@ -0,0 +1,39 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from sqlmodel import Field, Relationship, SQLModel
|
||||
|
||||
from app.db.base import TimestampMixin
|
||||
|
||||
|
||||
class RefreshToken(TimestampMixin, SQLModel, table=True):
|
||||
__tablename__ = "refresh_tokens"
|
||||
|
||||
id: int | None = Field(default=None, primary_key=True)
|
||||
user_id: int = Field(foreign_key="users.id", index=True)
|
||||
token: str = Field(max_length=500, unique=True, index=True)
|
||||
expires_at: datetime
|
||||
is_revoked: bool = Field(default=False)
|
||||
device_info: str = Field(default="", max_length=255)
|
||||
|
||||
# Relationships
|
||||
user: User | None = Relationship(back_populates="refresh_tokens")
|
||||
|
||||
|
||||
class OAuthAccount(TimestampMixin, SQLModel, table=True):
|
||||
__tablename__ = "oauth_accounts"
|
||||
|
||||
id: int | None = Field(default=None, primary_key=True)
|
||||
user_id: int = Field(foreign_key="users.id", index=True)
|
||||
provider: str = Field(max_length=50)
|
||||
provider_user_id: str = Field(max_length=255)
|
||||
access_token: str = Field(default="", max_length=500)
|
||||
refresh_token: str = Field(default="", max_length=500)
|
||||
expires_at: datetime | None = Field(default=None)
|
||||
|
||||
|
||||
# Avoid circular import
|
||||
from app.models.mariadb.user import User # noqa: E402, F811
|
||||
|
||||
RefreshToken.model_rebuild()
|
||||
Reference in New Issue
Block a user