refactor(services): make local secret setting public

This commit is contained in:
Houkime 2023-04-19 13:59:03 +00:00
parent 65acd3173a
commit fa360655fe

View file

@ -23,10 +23,14 @@ class LocalBackupSecret:
LocalBackupSecret.reset() LocalBackupSecret.reset()
return redis.get(REDIS_KEY) return redis.get(REDIS_KEY)
@staticmethod
def set(secret: str):
redis.set(REDIS_KEY, secret)
@staticmethod @staticmethod
def reset(): def reset():
new_secret = LocalBackupSecret._generate() new_secret = LocalBackupSecret._generate()
LocalBackupSecret._store(new_secret) LocalBackupSecret.set(new_secret)
@staticmethod @staticmethod
def exists() -> bool: def exists() -> bool:
@ -35,7 +39,3 @@ class LocalBackupSecret:
@staticmethod @staticmethod
def _generate() -> str: def _generate() -> str:
return secrets.token_urlsafe(256) return secrets.token_urlsafe(256)
@staticmethod
def _store(secret: str):
redis.set(REDIS_KEY, secret)