本文整理汇总了Python中flaskext.login.LoginManager.user_loader方法的典型用法代码示例。如果您正苦于以下问题:Python LoginManager.user_loader方法的具体用法?Python LoginManager.user_loader怎么用?Python LoginManager.user_loader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flaskext.login.LoginManager
的用法示例。
在下文中一共展示了LoginManager.user_loader方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup_interactive
# 需要导入模块: from flaskext.login import LoginManager [as 别名]
# 或者: from flaskext.login.LoginManager import user_loader [as 别名]
def setup_interactive(app):
lm = LoginManager()
lm.login_view = "login"
lm.user_loader(get_user)
@lm.unauthorized_handler
def unauth():
return "UNAUTHORIZED!"
lm.setup_app(app)
示例2: logging_in
# 需要导入模块: from flaskext.login import LoginManager [as 别名]
# 或者: from flaskext.login.LoginManager import user_loader [as 别名]
def logging_in(app):
lm = LoginManager()
lm.login_view = "login"
lm.user_loader(get_user)
lm.setup_app(app)
app.preprocess_request()
assert not current_user.is_authenticated()
assert current_user.is_anonymous()
with assert_fired(user_logged_in):
login_user(notch)
assert current_user.name == u"Notch"
assert session["user_id"] == u"1"
示例3: LoginManager
# 需要导入模块: from flaskext.login import LoginManager [as 别名]
# 或者: from flaskext.login.LoginManager import user_loader [as 别名]
import json
from urllib import urlencode
from urlparse import parse_qs, parse_qsl, urlsplit, urlunsplit
from flask import redirect, request, session, url_for
from flaskext.login import LoginManager, login_user, logout_user
import oauth2
import requests
from makerbase import app
from makerbase.models import User
login_manager = LoginManager()
login_manager.setup_app(app, add_context_processor=True)
login_manager.user_loader(User.get)
@app.route('/signin/github')
def signin_github():
try:
next_url = request.args['next']
except KeyError:
pass
else:
session['signin_next_url'] = next_url
urlparts = urlsplit(request.base_url)
params = {
'client_id': app.config['GITHUB_CLIENT_ID'],
'redirect_url': urlunsplit((urlparts.scheme, urlparts.netloc, url_for('complete_github'), None, None)),