|
@@ -8,14 +8,57 @@
|
|
|
#include <vector>
|
|
|
#include <sstream>
|
|
|
|
|
|
+/**
|
|
|
+ * @Class UserManager
|
|
|
+ *
|
|
|
+ * Handle differnt users with passwords and store them
|
|
|
+ */
|
|
|
class UserManager {
|
|
|
public:
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Makes shure that there is a user storage.
|
|
|
+ * If not. It creates a new one
|
|
|
+ */
|
|
|
static void init();
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Checks if a given user with password is valid
|
|
|
+ *
|
|
|
+ * @param user the name of the users
|
|
|
+ * @param pw password in plain text
|
|
|
+ */
|
|
|
static bool isAllowed(std::string user, std::string pw);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Add a new user and write to storage.
|
|
|
+ *
|
|
|
+ * @param user the name of the users
|
|
|
+ * @param pw password in plain text
|
|
|
+ */
|
|
|
static void addUser(std::string name, std::string pw);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Delete a new user and delete from storage.
|
|
|
+ *
|
|
|
+ * @param user the name of the users
|
|
|
+ * @param pw password in plain text
|
|
|
+ */
|
|
|
static void deleteUser(std::string name, std::string pw);
|
|
|
private:
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Read data from file and create map.
|
|
|
+ *
|
|
|
+ * @param user_map pointer to the map
|
|
|
+ */
|
|
|
static void readFromFile(std::map<std::string,std::string> *user_map);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Write data to afile
|
|
|
+ *
|
|
|
+ * @param user_map pointer to the map
|
|
|
+ */
|
|
|
static void writeToFile(std::map<std::string,std::string> *user_map);
|
|
|
};
|
|
|
|