Пофиксил апи сохранения токенов и режим отладки
This commit is contained in:
@@ -26,9 +26,12 @@ class Application(tk.Tk):
|
||||
def login(self):
|
||||
"""Возвращает пользователя - его можно потом сериализовать"""
|
||||
# Пользователь сохранен! Авторизация не нужна!
|
||||
user = User.load()
|
||||
if user is not None:
|
||||
return user
|
||||
try:
|
||||
user = User.load()
|
||||
if user is not None:
|
||||
return user
|
||||
except Exception as e:
|
||||
print("Failed to restore login:", e)
|
||||
# Не удалось - нужен логин
|
||||
self.frame = LoginFrame(master=self, url=DEFAULT_URL)
|
||||
while not self.frame.loggedIn:
|
||||
|
||||
@@ -161,6 +161,9 @@ class User(UserApi):
|
||||
"""
|
||||
Remove the login file from homedir
|
||||
"""
|
||||
if "DEBUG" in os.environ:
|
||||
print("Debug mode is on - no login storing")
|
||||
return
|
||||
if not os.path.exists(USER_TOKEN_PATH):
|
||||
return
|
||||
try:
|
||||
@@ -172,6 +175,9 @@ class User(UserApi):
|
||||
"""
|
||||
Store user token in homedir
|
||||
"""
|
||||
if "DEBUG" in os.environ:
|
||||
print("Debug mode is on - no login storing")
|
||||
return
|
||||
try:
|
||||
with open(USER_TOKEN_PATH, "w") as handler:
|
||||
json.dump(self.token.__dict__, handler)
|
||||
@@ -183,6 +189,8 @@ class User(UserApi):
|
||||
"""
|
||||
Restore user token from the file in homedir
|
||||
"""
|
||||
if "DEBUG" in os.environ:
|
||||
raise RuntimeError("Debug mode is on - no login storing")
|
||||
if os.path.exists(USER_TOKEN_PATH):
|
||||
try:
|
||||
with open(USER_TOKEN_PATH, "r") as handler:
|
||||
|
||||
Reference in New Issue
Block a user