Skip to content
This repository has been archived by the owner on Aug 30, 2019. It is now read-only.

Commit

Permalink
Little Logged session fix
Browse files Browse the repository at this point in the history
  • Loading branch information
pauloromeira committed May 6, 2018
1 parent 4a07097 commit 969bf4a
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions onegram/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,19 @@ def __init__(self, username=None, password=None, custom_settings={}):
super(Login, self).__init__(custom_settings)

self.username = self.settings.get('USERNAME')
self.on_open.subscribe(self._login)
# TODO [romeira]: fix sessionlib {06/05/18 04:41}
# self.on_open.subscribe(self._login)


def enter_contexts(self):
yield from super(Login, self).enter_contexts()
try:
self._login()
except AuthException as e:
self.logger.error(e)
self.close()
raise e


def _login(self):
kw = {}
Expand All @@ -172,12 +184,7 @@ def _login(self):

response = self._requests.post(URLS['login'], **kw)
response.raise_for_status()
try:
check_auth(json.loads(response.text))
except AuthException as e:
self.logger.error(e)
self.close()
raise e
check_auth(json.loads(response.text))
self.user_id = self.cookies.get('ds_user_id')


Expand Down

0 comments on commit 969bf4a

Please sign in to comment.