37 lines
907 B
Python
37 lines
907 B
Python
from typing import Optional
|
|
from uuid import UUID
|
|
from pydantic import field_validator
|
|
|
|
from ApiLayers.AllConfigs.Redis.configs import RedisAuthKeys
|
|
from Services.RedisService.Models.row import BaseRedisModel
|
|
|
|
|
|
class AccessToken(BaseRedisModel):
|
|
|
|
auth_key: Optional[str] = RedisAuthKeys.AUTH
|
|
accessToken: Optional[str] = None
|
|
userUUID: Optional[str | UUID] = None
|
|
|
|
@field_validator("userUUID", mode="after")
|
|
def validate_uuid(cls, v):
|
|
"""Convert UUID to string during validation."""
|
|
if v is None:
|
|
return None
|
|
return str(v)
|
|
|
|
def to_list(self):
|
|
"""Convert to list for Redis storage."""
|
|
return [
|
|
self.auth_key,
|
|
self.accessToken,
|
|
str(self.userUUID) if self.userUUID else None,
|
|
]
|
|
|
|
@property
|
|
def count(self):
|
|
return 3
|
|
|
|
@property
|
|
def delimiter(self):
|
|
return ":"
|