May 2018
Intermediate to advanced
380 pages
9h 37m
English
Once the Flask modules are imported, the login decorator function provides the main logic for handling user authentication. The Python standard library's @wraps() decorator call does the same thing we have done previously with the def wrapper() function, except we are utilizing the functools.wraps function provided by Flask. This is necessary because the login decorator wraps and replaces the original function; without a wrapper, that original data would be lost during the handover.
The decorated_function() takes any number of arguments, either as positional or keyword:value pairs. This function first checks to see whether the global object g.user is None, that is, a user not logged in. If this is the case, the user is automatically ...