Skip to content

Instantly share code, notes, and snippets.

@spiralswimmer
Created May 18, 2018 15:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spiralswimmer/526a302d2ea883dd06e8dfcff05ae911 to your computer and use it in GitHub Desktop.
Save spiralswimmer/526a302d2ea883dd06e8dfcff05ae911 to your computer and use it in GitHub Desktop.
💩
def __get_user(self, userid=None, email=None, phone=None, fbid=None):
ret_u = None
if fbid == None and phone == None and email == None and userid == None:
return None
if userid:
q = {'userid': userid}
users = self.db.find_cfg_coll('dbname', 'users', q)
for u in users:
ret_u = u
break
if ret_u == None and fbid:
q = {'fb.id': fbid}
users = self.db.find_cfg_coll('dbname', 'users', q)
for u in users:
ret_u = u
break
if ret_u == None and phone:
q = {'info.phone': phone}
users = self.db.find_cfg_coll('dbname', 'users', q)
for u in users:
ret_u = u
break
if ret_u == None and email:
q = {'info.email': email}
users = self.db.find_cfg_coll('dbname', 'users', q)
for u in users:
ret_u = u
break
if ret_u and 'info' in ret_u and 'fb' in ret_u and 'id' in ret_u['fb']:
ret_u['info']['picture'] = fb.get_fb_picture(ret_u['fb']['id'])
# adding some profile keys
if ret_u and 'personal_profile' not in ret_u.keys():
ret_u['personal_profile'] = USER_PROFILE_KEYS
return ret_u
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment