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

Commit

Permalink
-Introduced Config.compile_anon_session method.
Browse files Browse the repository at this point in the history
-First connection now is based on Config.compile_anon_session method rather than calling database.
  • Loading branch information
mahmoudajawad committed Apr 1, 2019
1 parent 5315574 commit 4e340a6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
14 changes: 13 additions & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,16 @@ def config_data(self, modules):
for doc in self.docs:
doc_results = modules[doc['module']].methods['read'](skip_events=[Event.__PERM__, Event.__PRE__, Event.__ON__], query={'_id':{'val':doc['doc']['_id']}})
if not doc_results.args.count:
modules[doc['module']].methods['create'](skip_events=[Event.__PERM__], doc=doc['doc'])
modules[doc['module']].methods['create'](skip_events=[Event.__PERM__], doc=doc['doc'])

@classmethod
def compile_anon_session(self):
return {
'_id': ObjectId('f00000000000000000000012'),
'user': ObjectId('f00000000000000000000011'),
'host_add': '127.0.0.1',
'user_agent': self.anon_token,
'timestamp': datetime.datetime.fromtimestamp(86400) - datetime.timedelta(days=1),
'expiry': datetime.datetime.fromtimestamp(86400) - datetime.timedelta(days=1),
'token': self.anon_token
}
3 changes: 1 addition & 2 deletions limpd.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ async def websocket_handler(request):
try:
session.token
except Exception:
session_results = modules['session'].methods['read'](skip_events=[Event.__PERM__], query={'_id':{'val':ObjectId('f00000000000000000000012')}})
session = session_results.args.docs[0]
session = DictObj(Config.compile_anon_session())
res = json.loads(msg.data)
# if (res.keys().__len__() == 1 and list(res.keys())[0] == 'token'):
logger.debug('attempting to decode JWT: %s, %s', res['token'], session.token)
Expand Down

0 comments on commit 4e340a6

Please sign in to comment.