MCPcopy Create free account
hub / github.com/pallets/flask / login_required

Function login_required

examples/tutorial/flaskr/auth.py:19–29  ·  view source on GitHub ↗

View decorator that redirects anonymous users to the login page.

(view)

Source from the content-addressed store, hash-verified

17
18
19def login_required(view):
20 """View decorator that redirects anonymous users to the login page."""
21
22 @functools.wraps(view)
23 def wrapped_view(**kwargs):
24 if g.user is None:
25 return redirect(url_for("auth.login"))
26
27 return view(**kwargs)
28
29 return wrapped_view
30
31
32@bp.before_app_request

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected