Browse Source

Fix redis response decoding

master
Sergey Zhuplev 8 months ago
parent
commit
55b28d5b09
1 changed files with 6 additions and 4 deletions
  1. +6
    -4
      sso_client/storage.py

+ 6
- 4
sso_client/storage.py View File

@ -1,4 +1,5 @@
from abc import ABC
from typing import Optional
from redis import Redis
@ -10,7 +11,7 @@ class JWTStorage(ABC):
def set_expire(self, key: str, ttl: int, value: str):
raise NotImplementedError
def get(self, key: str):
def get(self, key: str) -> Optional[str]:
raise NotImplementedError
@ -21,8 +22,9 @@ class RedisJWTStorage(JWTStorage):
def set_expire(self, key: str, ttl: int, value: str):
self._redis.setex(key, ttl, value)
def get(self, key: str):
return self._redis.get(key)
def get(self, key: str) -> Optional[str]:
data = self._redis.get(key)
return data.decode() if data else None
def set(self, key: str, value: str):
self._redis.set(key, value)
@ -57,7 +59,7 @@ class DumbJWTStorage(JWTStorage):
"""
pass
def get(self, key: str):
def get(self, key: str) -> Optional[str]:
"""
Return None to force update jwt every time
:param key:


Loading…
Cancel
Save