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