123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- #ifndef USER_MANAGER_H
- #define USER_MANAGER_H
- #include <map>
- #include <iostream>
- #include <fstream>
- #include <string>
- #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);
- };
- #endif
|