本文整理汇总了Python中dao.UserDao.get_user_by_token方法的典型用法代码示例。如果您正苦于以下问题:Python UserDao.get_user_by_token方法的具体用法?Python UserDao.get_user_by_token怎么用?Python UserDao.get_user_by_token使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dao.UserDao
的用法示例。
在下文中一共展示了UserDao.get_user_by_token方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: resp
# 需要导入模块: from dao import UserDao [as 别名]
# 或者: from dao.UserDao import get_user_by_token [as 别名]
def resp(token, did):
user = UserDao.get_user_by_token(token)
if not user: return RESPONSE.WRONG_TOKEN
devices = DeviceDao.get_devices_by_user(user)
for device in devices:
if device['did'] == did:
#TODO 需要进行一些数据清理工作
return RESPONSE.SUCCESS
return RESPONSE.WRONG_DID
示例2: update
# 需要导入模块: from dao import UserDao [as 别名]
# 或者: from dao.UserDao import get_user_by_token [as 别名]
def update(token,did,loc_info):
user = UserDao.get_user_by_token(token)
if not user: return {'status':0, 'desc':'wrong token'}
device_loc = LocCollection.find_one({'did':did})
if device_loc:
device_loc['loc_info'].append(loc_info)
else:
device_loc = {
'did':did,
'loc_info': loc_info
}
LocCollection.update({'did':did}, device_loc, upsert=True)
return {'status':1}
示例3: pull
# 需要导入模块: from dao import UserDao [as 别名]
# 或者: from dao.UserDao import get_user_by_token [as 别名]
def pull(token, did):
user = UserDao.get_user_by_token(token)
if not user: return RESPONSE.WRONG_TOKEN
devices = DeviceDao.get_devices_by_user(user)
for device in devices:
if device['did'] == did:
#TODO 需要将具体的信息返回回去
RESPONSE.PULL_SUCCESS['data'] = device['pull_info']
device['pull_info']=[]
UserCollection.update({'token':user['token']},user)
return RESPONSE.PULL_SUCCESS
return RESPONSE.WRONG_DID
示例4: initial
# 需要导入模块: from dao import UserDao [as 别名]
# 或者: from dao.UserDao import get_user_by_token [as 别名]
def initial(token,phone,did,cid,imei):
user = UserDao.get_user_by_token(token)
if not user: return RESPONSE.WRONG_TOKEN
devices = DeviceDao.get_devices_by_user(user)
for device in devices:
if device['phone'] == phone:
device['did'] = did
device['cid'] = cid
device['imei'] = imei
UserCollection.update({'tid':user['tid']},user)
#TODO 需要增加client对初始化配置信息
RESPONSE.INITIAL_SUCCESS['initial'] = {}
return RESPONSE.INITIAL_SUCCESS
return RESPONSE.WRONG_PHONE
示例5: test_get_user_by_token
# 需要导入模块: from dao import UserDao [as 别名]
# 或者: from dao.UserDao import get_user_by_token [as 别名]
def test_get_user_by_token():
user = UserDao.get_user_by_email(email)
user2 = UserDao.get_user_by_token(user['token'])
assert user2['email'] == email