本文整理汇总了Python中api.models.User.claimed方法的典型用法代码示例。如果您正苦于以下问题:Python User.claimed方法的具体用法?Python User.claimed怎么用?Python User.claimed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类api.models.User
的用法示例。
在下文中一共展示了User.claimed方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: login
# 需要导入模块: from api.models import User [as 别名]
# 或者: from api.models.User import claimed [as 别名]
def login():
params = request.json
access_token = params.get('accessToken')
fb_id = params['fbId']
user = get_user(fb_id, by_fb_id=True)
if user is None:
if access_token is None:
raise APIException('please provide accessToken', 400)
else:
if not facebook.verify(fb_id, access_token):
raise APIException("access token invalid", 403)
user = User(fb_id=fb_id, access_token=access_token,
fullname=params['fullName'],
image_link=params['imageLink'],
badge_setting=params.get('badgeSetting'),
device_token=params.get('deviceToken'),
badge_num=0,
claimed=True)
db.session.add(user)
db.session.commit()
else:
if access_token is None:
assert_user_is_unclaimed(user)
else:
if not facebook.verify(fb_id, access_token):
raise APIException("access token invalid", 403)
if user.claimed == False:
user.claimed = True
db.session.add(user)
db.session.commit()
if login_user(user, remember=True):
session.permanent = True
return jsonify(user.dictify())
# Why would this happen?
raise APIException('could not log in', 400)