mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-26 14:01:30 +00:00
refactor(services): make local secret setting public
This commit is contained in:
parent
65acd3173a
commit
fa360655fe
|
@ -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)
|
|
||||||
|
|
Loading…
Reference in a new issue