Call applySessionTimeouts before writing data

Before writing bmcweb_persistent_data.json on bmcweb shutdown call
applySessionTimeouts() to ensure no stale sessions are wrote.

To accomplish this had to move applySessionTimeouts to public.

Tested: Stop bmcweb, modify bmcweb_persistent_data.json timeout to
        be 30 seconds. Start bmcweb. Verify timeout 30 seconds and
        1 session is restored. Wait 1 min. stop bmcweb. Verify
        no sessions in bmcweb_persistent_data.json.
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>

Change-Id: Idfaf7c144b3bdeb2741b48f603d7213ac1a51f10
diff --git a/include/sessions.hpp b/include/sessions.hpp
index 7cdb82a..1eace0d 100644
--- a/include/sessions.hpp
+++ b/include/sessions.hpp
@@ -346,23 +346,6 @@
         return sessionStore;
     }
 
-    SessionStore(const SessionStore&) = delete;
-    SessionStore& operator=(const SessionStore&) = delete;
-
-    std::unordered_map<std::string, std::shared_ptr<UserSession>,
-                       std::hash<std::string>,
-                       crow::utility::ConstantTimeCompare>
-        authTokens;
-
-    std::chrono::time_point<std::chrono::steady_clock> lastTimeoutUpdate;
-    bool needWrite{false};
-    std::chrono::seconds timeoutInSeconds;
-    AuthConfigMethods authMethodsConfig;
-
-  private:
-    SessionStore() : timeoutInSeconds(3600)
-    {}
-
     void applySessionTimeouts()
     {
         auto timeNow = std::chrono::steady_clock::now();
@@ -390,6 +373,23 @@
             }
         }
     }
+
+    SessionStore(const SessionStore&) = delete;
+    SessionStore& operator=(const SessionStore&) = delete;
+
+    std::unordered_map<std::string, std::shared_ptr<UserSession>,
+                       std::hash<std::string>,
+                       crow::utility::ConstantTimeCompare>
+        authTokens;
+
+    std::chrono::time_point<std::chrono::steady_clock> lastTimeoutUpdate;
+    bool needWrite{false};
+    std::chrono::seconds timeoutInSeconds;
+    AuthConfigMethods authMethodsConfig;
+
+  private:
+    SessionStore() : timeoutInSeconds(3600)
+    {}
 };
 
 } // namespace persistent_data