diff --git a/spectrum_manager/src/html/header.html b/spectrum_manager/src/html/header.html
index f4baa073..b3dce4d9 100644
--- a/spectrum_manager/src/html/header.html
+++ b/spectrum_manager/src/html/header.html
@@ -20,9 +20,9 @@
diff --git a/spectrum_manager/src/server.cpp b/spectrum_manager/src/server.cpp
index b255f505..bb3d3d38 100644
--- a/spectrum_manager/src/server.cpp
+++ b/spectrum_manager/src/server.cpp
@@ -229,6 +229,7 @@ std::string Server::send_command(const std::string &jid, const std::string &cmd)
struct timeval td_start,td_end;
float elapsed = 0;
gettimeofday(&td_start, NULL);
+ gettimeofday(&td_end, NULL);
time_t started = time(NULL);
while(get_response().empty() && td_end.tv_sec - td_start.tv_sec < 1) {
@@ -291,7 +292,24 @@ void Server::serve_cmd(struct mg_connection *conn, struct http_message *hm) {
print_html(conn, hm, html);
}
+void Server::serve_logout(struct mg_connection *conn, struct http_message *hm) {
+ Server:session *session = get_session(hm);
+ mg_printf(conn, "HTTP/1.1 302 Found\r\n"
+ "Set-Cookie: session=%s; max-age=0\r\n" // Session ID
+ "Location: /\r\n\r\n",
+ session->session_id);
+
+ sessions.erase(session->session_id);
+ delete session;
+}
+
void Server::serve_users_add(struct mg_connection *conn, struct http_message *hm) {
+ Server:session *session = get_session(hm);
+ if (!session->admin) {
+ redirect_to(conn, hm, "/");
+ return;
+ }
+
std::string user = get_http_var(hm, "user");
std::string password = get_http_var(hm, "password");
@@ -306,6 +324,24 @@ void Server::serve_users_add(struct mg_connection *conn, struct http_message *hm
redirect_to(conn, hm, "/users");
}
+void Server::serve_users_remove(struct mg_connection *conn, struct http_message *hm) {
+ Server:session *session = get_session(hm);
+ if (!session->admin) {
+ redirect_to(conn, hm, "/");
+ return;
+ }
+
+ if (!m_storage) {
+ return;
+ }
+
+ std::string user = get_http_var(hm, "user");
+ UserInfo info;
+ m_storage->getUser(user, info);
+ m_storage->removeUser(info.id);
+ redirect_to(conn, hm, "/users");
+}
+
void Server::serve_users(struct mg_connection *conn, struct http_message *hm) {
std::string html = "
User | Action | ||
---|---|---|---|
" + jid + " | "; - html += ""; + html += " | " + user + " | "; + html += "Remove | "; html += "