From 52d64d86d88b1bd127b34043b59cc22aa18d4186 Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Thu, 17 Nov 2022 16:19:03 -0600 Subject: [PATCH] Add sessions only after authorise returns True --- src/sessionmanager/manager.py | 13 ------------- src/sessionmanager/sessionManager.py | 10 ++++------ 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/src/sessionmanager/manager.py b/src/sessionmanager/manager.py index 57d58156..89d95503 100644 --- a/src/sessionmanager/manager.py +++ b/src/sessionmanager/manager.py @@ -21,19 +21,6 @@ class sessionManager(object): if self.is_valid(config.app["sessions"]["current_session"]): return config.app["sessions"]["current_session"] - def add_session(self, id): - """ Adds a new session to the global config, so it will be taken into account for all operations. - - :param id: Session identified. - :param id: str. - """ - log.debug("Adding a new session: %s" % (id,)) - path = os.path.join(paths.config_path(), id) - if not os.path.exists(path): - log.debug("Creating %s path" % (os.path.join(paths.config_path(), path),)) - os.mkdir(path) - config.app["sessions"]["sessions"].append(id) - def set_current_session(self, sessionID): config.app["sessions"]["current_session"] = sessionID config.app.write() diff --git a/src/sessionmanager/sessionManager.py b/src/sessionmanager/sessionManager.py index 6183b2f6..b8d4171f 100644 --- a/src/sessionmanager/sessionManager.py +++ b/src/sessionmanager/sessionManager.py @@ -123,12 +123,10 @@ class sessionManagerController(object): s = TwitterSession.Session(location) elif type == "mastodon": s = MastodonSession.Session(location) - manager.manager.add_session(location) - s.get_configuration() - s.authorise() - self.sessions.append(dict(id=location, type=type)) - self.view.add_new_session_to_list() - s.settings.write() + result = s.authorise() + if result == True: + self.sessions.append(dict(id=location, type=type)) + self.view.add_new_session_to_list() def remove_account(self, index): selected_account = self.sessions[index]