Skip to content
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

Open
wants to merge 2 commits into
base: users
Choose a base branch
from

Conversation

ilya-shevelev
Copy link

Methods of the "Token" class interacting with Redis are moved to 2 classes: RedisAccessToken and RedisBanRefreshToken

@kieled kieled added the users label Jul 27, 2023
Comment on lines 5 to 8
class RedisToken:
@staticmethod
def add_token_to_redis(redis_client: RedisClient, token: str, value: dict):
redis_client.add_token(token=token, value=value)
Copy link
Collaborator

@oxpaoff oxpaoff Jul 30, 2023

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)

Comment on lines 19 to 24
@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)
Copy link
Collaborator

@oxpaoff oxpaoff Jul 30, 2023

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):
Copy link
Collaborator

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)

Comment on lines 16 to 29
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,
)

Copy link
Collaborator

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()

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

и потом через self вызывать

@ilya-shevelev
Copy link
Author

Исправил и изменил "redis_access_client" и "redis_refresh_client" на "client" в обоих классах (RedisAccessToken и RedisBanRefreshToken).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants