本文整理汇总了Python中User.objects方法的典型用法代码示例。如果您正苦于以下问题:Python User.objects方法的具体用法?Python User.objects怎么用?Python User.objects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类User
的用法示例。
在下文中一共展示了User.objects方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: login
# 需要导入模块: import User [as 别名]
# 或者: from User import objects [as 别名]
def login(provider_name):
response = make_response()
result = current_app.authomatic.login(
WerkzeugAdapter(request, response), provider_name
)
if result:
if result.user:
first_login = False
result.user.update()
user = User.objects(provider=provider_name, user_id=result.user.id).first()
if user is None:
user = User(
username=result.user.username,
email=result.user.email,
name=result.user.name,
user_id=result.user.id,
provider=provider_name
)
user.save()
first_login = True
else:
user.name = result.user.name
user.email = result.user.email
user.save()
session['user_id'] = user.user_id
return redirect_next()
flash_error('Authentication failed')
return redirect(url_for('auth.login_page', next=request.path))
return response
示例2: before_app_request
# 需要导入模块: import User [as 别名]
# 或者: from User import objects [as 别名]
def before_app_request():
g.user = None
if 'user_id' in session:
g.user = User.objects(user_id=session['user_id']).first()