Fix some moves

This code is doing some copy operations instead of moves.  This commit
moves to passing a Request&& through the validate function, so that we
don't have to split the usage of req between the two paths.

Ideally someday we'd run Request as a shared_ptr like we do with
Response and remove the possibility of this, but that's a longer term
thing.

This fixes a regression introduced in
7e9093e625961f533250a6c193c1a474e98007c4

Tested:
Redfish service validator passes.

/redfish/v1/Systems/system passes.

Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: Ib6d99726a64326b7c8bad15bc9d4ca774ab6256d
diff --git a/http/routing.hpp b/http/routing.hpp
index e86c774..5bf6c90 100644
--- a/http/routing.hpp
+++ b/http/routing.hpp
@@ -1335,7 +1335,7 @@
     }
 
     template <typename CallbackFn>
-    void afterGetUserInfo(Request& req,
+    void afterGetUserInfo(Request&& req,
                           const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
                           BaseRule& rule, CallbackFn&& callback,
                           const boost::system::error_code& ec,
@@ -1356,26 +1356,30 @@
             asyncResp->res.result(boost::beast::http::status::forbidden);
             return;
         }
-        callback();
+        callback(std::move(req));
     }
 
     template <typename CallbackFn>
-    void validatePrivilege(Request& req,
+    void validatePrivilege(Request&& req,
                            const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
                            BaseRule& rule, CallbackFn&& callback)
     {
+        if (req.session == nullptr)
+        {
+            return;
+        }
+        std::string username = req.session->username;
         crow::connections::systemBus->async_method_call(
-            [this, &req, asyncResp, &rule,
+            [this, req{std::move(req)}, asyncResp, &rule,
              callback(std::forward<CallbackFn>(callback))](
                 const boost::system::error_code& ec,
                 const dbus::utility::DBusPropertiesMap& userInfoMap) mutable {
-            afterGetUserInfo(req, asyncResp, rule,
+            afterGetUserInfo(std::move(req), asyncResp, rule,
                              std::forward<CallbackFn>(callback), ec,
                              userInfoMap);
             },
             "xyz.openbmc_project.User.Manager", "/xyz/openbmc_project/user",
-            "xyz.openbmc_project.User.Manager", "GetUserInfo",
-            req.session->username);
+            "xyz.openbmc_project.User.Manager", "GetUserInfo", username);
     }
 
     template <typename Adaptor>
@@ -1426,11 +1430,12 @@
 
         // TODO(ed) This should be able to use std::bind_front, but it doesn't
         // appear to work with the std::move on adaptor.
-        validatePrivilege(req, asyncResp, rule,
-                          [&rule, &req, asyncResp,
-                           adaptor(std::forward<Adaptor>(adaptor))]() mutable {
-            rule.handleUpgrade(req, asyncResp, std::move(adaptor));
-        });
+        validatePrivilege(
+            std::move(req), asyncResp, rule,
+            [&rule, asyncResp, adaptor(std::forward<Adaptor>(adaptor))](
+                Request&& thisReq) mutable {
+            rule.handleUpgrade(thisReq, asyncResp, std::move(adaptor));
+            });
     }
 
     void handle(Request& req,
@@ -1498,11 +1503,11 @@
             rule.handle(req, asyncResp, params);
             return;
         }
-
-        validatePrivilege(req, asyncResp, rule,
-                          std::bind_front(&BaseRule::handle, std::ref(rule),
-                                          std::ref(req), asyncResp,
-                                          std::ref(params)));
+        validatePrivilege(
+            std::move(req), asyncResp, rule,
+            [&rule, asyncResp, params](Request&& thisReq) mutable {
+            rule.handle(thisReq, asyncResp, params);
+            });
     }
 
     void debugPrint()