浏览代码

added user management to server and main

marius.rescheleit 4 年之前
父节点
当前提交
7700e4e360
共有 2 个文件被更改,包括 7 次插入2 次删除
  1. 4 2
      daemon/src/Server.cpp
  2. 3 0
      daemon/src/main.cpp

+ 4 - 2
daemon/src/Server.cpp

@@ -1,5 +1,6 @@
 #include "../include/Server.h"
 #include "../include/base64.h"
+#include "../include/user_manager.h"
 
 #include <iostream>
 
@@ -93,8 +94,9 @@ void con_handler::handle_read_login(const boost::system::error_code &err,
 
     // user credentials
     // TODO check user credentials!!!
-    if (root["user"].asString().compare("user") == 0 &&
-        root["pass"].asString().compare("pass") == 0) {
+    // if (root["user"].asString().compare("user") == 0 &&
+        // root["pass"].asString().compare("pass") == 0) {
+    if (UserManager::isAllowed(root["user"].asString(), root["pass"].asString())) {
       answer["accept"] = true;
 
       // read next data

+ 3 - 0
daemon/src/main.cpp

@@ -3,6 +3,7 @@
 
 #include "../include/Server.h"
 #include "../include/Sniffer.h"
+#include "../include/user_manager.h"
 
 using namespace std;
 
@@ -12,6 +13,8 @@ int main(int argc, char *argv[]) {
     return 0;
   }
 
+  UserManager::init();
+
   const string interface = argv[1];
   Sniffer *sniffer = new Sniffer(interface);
   thread snifferThread(&Sniffer::startSniffing, sniffer);