inventorymgr/auth.py
def authentication_required(to_be_wrapped: Callable[..., Any]) -> Callable[..., Any]:
    """Wraps a view with a check for whether the user is authenticated."""

    @functools.wraps(to_be_wrapped)
    def wrapper(*args: Any, **kwargs: Any) -> Any:
        user_id = session.get("user_id")
        if user_id is None or User.query.get(user_id) is None:
            if "user_id" in session:
                del session["user_id"]
            response = make_response({"reason": "authentication_required"}, 403)
            response.set_cookie("is_authenticated", max_age=0, expires=0)
            return response
        return to_be_wrapped(*args, **kwargs)

    return wrapper
Wraps a view with a check for whether the user is authenticated.
Wraps a view with a check for whether the user is authenticated.
Wraps a view with a check for whether the user is authenticated .
def authentication_required(to_be_wrapped: Callable[..., Any]) -> Callable[..., Any]:
    @functools.wraps(to_be_wrapped)
    def wrapper(*args: Any, **kwargs: Any) -> Any:
        user_id = session.get("user_id")
        if user_id is None or User.query.get(user_id) is None:
            if "user_id" in session:
                del session["user_id"]
            response = make_response({"reason": "authentication_required"}, 403)
            response.set_cookie("is_authenticated", max_age=0, expires=0)
            return response
        return to_be_wrapped(*args, **kwargs)
    return wrapper
def authentication_required ( to_be_wrapped : Callable [ ... , Any ] ) -> Callable [ ... , Any ] : @ functools . wraps ( to_be_wrapped ) def wrapper ( * args : Any , ** kwargs : Any ) -> Any : user_id = session . get ( "user_id" ) if user_id is None or User . query . get ( user_id ) is None : if "user_id" in session : del session [ "user_id" ] response = make_response ( { "reason" : "authentication_required" } , 403 ) response . set_cookie ( "is_authenticated" , max_age = 0 , expires = 0 ) return response return to_be_wrapped ( * args , ** kwargs ) return wrapper
Wraps a view with a check for whether the user is authenticated.
Wraps a view with a check for whether the user is authenticated .
"""Wraps a view with a check for whether the user is authenticated."""
to_be_wrapped
Callable[..., Any]