mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-22 19:28:09 -06:00
Add sessions only after authorise returns True
This commit is contained in:
parent
2ab61ebee6
commit
52d64d86d8
@ -21,19 +21,6 @@ class sessionManager(object):
|
|||||||
if self.is_valid(config.app["sessions"]["current_session"]):
|
if self.is_valid(config.app["sessions"]["current_session"]):
|
||||||
return 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):
|
def set_current_session(self, sessionID):
|
||||||
config.app["sessions"]["current_session"] = sessionID
|
config.app["sessions"]["current_session"] = sessionID
|
||||||
config.app.write()
|
config.app.write()
|
||||||
|
@ -123,12 +123,10 @@ class sessionManagerController(object):
|
|||||||
s = TwitterSession.Session(location)
|
s = TwitterSession.Session(location)
|
||||||
elif type == "mastodon":
|
elif type == "mastodon":
|
||||||
s = MastodonSession.Session(location)
|
s = MastodonSession.Session(location)
|
||||||
manager.manager.add_session(location)
|
result = s.authorise()
|
||||||
s.get_configuration()
|
if result == True:
|
||||||
s.authorise()
|
self.sessions.append(dict(id=location, type=type))
|
||||||
self.sessions.append(dict(id=location, type=type))
|
self.view.add_new_session_to_list()
|
||||||
self.view.add_new_session_to_list()
|
|
||||||
s.settings.write()
|
|
||||||
|
|
||||||
def remove_account(self, index):
|
def remove_account(self, index):
|
||||||
selected_account = self.sessions[index]
|
selected_account = self.sessions[index]
|
||||||
|
Loading…
Reference in New Issue
Block a user