updated login/select
This commit is contained in:
@@ -2,11 +2,13 @@ from typing import Optional
|
||||
from uuid import UUID
|
||||
from pydantic import field_validator
|
||||
|
||||
from ApiLayers.AllConfigs.Redis.configs import RedisAuthKeys
|
||||
from Services.Redis.Models.row import BaseRedisModel
|
||||
|
||||
|
||||
class AccessToken(BaseRedisModel):
|
||||
|
||||
auth_key: Optional[str] = RedisAuthKeys.AUTH
|
||||
accessToken: Optional[str] = None
|
||||
userUUID: Optional[str | UUID] = None
|
||||
|
||||
@@ -19,7 +21,7 @@ class AccessToken(BaseRedisModel):
|
||||
|
||||
def to_list(self):
|
||||
"""Convert to list for Redis storage."""
|
||||
return [self.accessToken, str(self.userUUID) if self.userUUID else None]
|
||||
return [self.auth_key, self.accessToken, str(self.userUUID) if self.userUUID else None]
|
||||
|
||||
@property
|
||||
def count(self):
|
||||
|
||||
@@ -29,9 +29,7 @@ class RedisResponse:
|
||||
def as_dict(self) -> Dict:
|
||||
data = self.all
|
||||
main_dict = {
|
||||
"status": self.status,
|
||||
"message": self.message,
|
||||
"count": self.count,
|
||||
"status": self.status, "message": self.message, "count": self.count,
|
||||
"dataType": getattr(self, "data_type", None),
|
||||
}
|
||||
if isinstance(data, RedisRow):
|
||||
@@ -49,7 +47,6 @@ class RedisResponse:
|
||||
|
||||
@property
|
||||
def count(self) -> int:
|
||||
print()
|
||||
row = self.all
|
||||
if isinstance(row, list):
|
||||
return len(row)
|
||||
@@ -57,13 +54,13 @@ class RedisResponse:
|
||||
return 1
|
||||
|
||||
@property
|
||||
def first(self) -> Union[RedisRow, None]:
|
||||
def first(self) -> Union[RedisRow, dict, None]:
|
||||
if self.data:
|
||||
if isinstance(self.data, list):
|
||||
if isinstance(self.data[0], RedisRow):
|
||||
return self.data[0].row
|
||||
return self.data[0]
|
||||
elif isinstance(self.data, RedisRow):
|
||||
return self.row
|
||||
return self.data.row
|
||||
self.status = False
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user