-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Users | Separation of the "Token" class #408
base: users
Are you sure you want to change the base?
Conversation
class RedisToken: | ||
@staticmethod | ||
def add_token_to_redis(redis_client: RedisClient, token: str, value: dict): | ||
redis_client.add_token(token=token, value=value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
можно избавиться от этого класс и в методах классов вместо
cls.add_token_to_redis(redis_client=cls.redis_access_client, token=token, value=value)
писать
self.redis_client.add_token(token=token, value=value)
@classmethod | ||
def add_access_to_redis(cls, token: str, value: dict): | ||
cls.add_token_to_redis(redis_client=cls.redis_access_client, token=token, value=value) | ||
|
||
def get_access_data(self, token: str) -> dict | None: | ||
return self.redis_access_client.is_token_exist(token) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
давай везде в названия методов уберем названия токена
тут методы будут
add(cls, token: str, value: dict)
и
def get_data(self, token: str) -> dict | None:
) | ||
|
||
@classmethod | ||
def add_refresh_to_redis(cls, token: str, value: dict = None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
а тут
ban(cls, token: str, value: dict = None)
redis_access_client = RedisAccessClient( | ||
host=redis_config.REDIS_SHARED_HOST, | ||
port=redis_config.REDIS_SHARED_PORT, | ||
db=redis_config.REDIS_ACCESS_DB, | ||
password=redis_config.REDIS_SHARED_PASSWORD, | ||
) | ||
|
||
redis_refresh_client = RedisRefreshClient( | ||
host=redis_config.REDIS_SHARED_HOST, | ||
port=redis_config.REDIS_SHARED_PORT, | ||
db=redis_config.REDIS_REFRESH_DB, | ||
password=redis_config.REDIS_SHARED_PASSWORD, | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
тут надо так
redis_access_client = RedisAccessToken()
redis_ban_refresh_client = RedisBanRefreshToken()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
и потом через self вызывать
Исправил и изменил "redis_access_client" и "redis_refresh_client" на "client" в обоих классах (RedisAccessToken и RedisBanRefreshToken). |
Methods of the "Token" class interacting with Redis are moved to 2 classes: RedisAccessToken and RedisBanRefreshToken