本文整理汇总了Python中flaskext.login.LoginManager.unauthorized方法的典型用法代码示例。如果您正苦于以下问题:Python LoginManager.unauthorized方法的具体用法?Python LoginManager.unauthorized怎么用?Python LoginManager.unauthorized使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flaskext.login.LoginManager
的用法示例。
在下文中一共展示了LoginManager.unauthorized方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: login_message
# 需要导入模块: from flaskext.login import LoginManager [as 别名]
# 或者: from flaskext.login.LoginManager import unauthorized [as 别名]
def login_message(app):
lm = LoginManager()
lm.login_view = "login"
lm.login_message = u"Log in or the owl will eat you."
lm.setup_app(app)
lm.unauthorized()
assert u"Log in or the owl will eat you." in get_flashed_messages()
示例2: unauthorized_redirect
# 需要导入模块: from flaskext.login import LoginManager [as 别名]
# 或者: from flaskext.login.LoginManager import unauthorized [as 别名]
def unauthorized_redirect(app):
lm = LoginManager()
lm.login_view = "login"
lm.setup_app(app)
res = lm.unauthorized()
assert res.headers["Location"] == "/login?next=%2F"
assert LOGIN_MESSAGE in get_flashed_messages()
示例3: unauthorized_callback
# 需要导入模块: from flaskext.login import LoginManager [as 别名]
# 或者: from flaskext.login.LoginManager import unauthorized [as 别名]
def unauthorized_callback(app):
lm = LoginManager()
lm.login_view = "login"
@lm.unauthorized_handler
def unauth():
return "UNAUTHORIZED!"
lm.setup_app(app)
assert lm.unauthorized() == "UNAUTHORIZED!"
assert len(get_flashed_messages()) == 0
示例4: unauthorized_401
# 需要导入模块: from flaskext.login import LoginManager [as 别名]
# 或者: from flaskext.login.LoginManager import unauthorized [as 别名]
def unauthorized_401(app):
lm = LoginManager()
lm.setup_app(app)
with raises(Unauthorized):
with assert_fired(user_unauthorized):
res = lm.unauthorized()