From ed670fc5a939a9030b3a0deb54afc023ad4abb04 Mon Sep 17 00:00:00 2001 From: Jan Kaluza Date: Thu, 21 Jan 2016 12:47:52 +0100 Subject: [PATCH] Web interface: remove useless serve_users* methods from Server class --- spectrum_manager/src/server.cpp | 110 -------------------------------- spectrum_manager/src/server.h | 3 - 2 files changed, 113 deletions(-) diff --git a/spectrum_manager/src/server.cpp b/spectrum_manager/src/server.cpp index 6a3ca56f..29b6ea34 100644 --- a/spectrum_manager/src/server.cpp +++ b/spectrum_manager/src/server.cpp @@ -388,116 +388,6 @@ void Server::serve_logout(struct mg_connection *conn, struct http_message *hm) { delete session; } -void Server::serve_users_add(struct mg_connection *conn, struct http_message *hm) { - std::string user = get_http_var(hm, "user"); - std::string password = get_http_var(hm, "password"); - - if (!user.empty() && !password.empty()) { - if (m_storage) { - UserInfo dummy; - bool registered = m_storage->getUser(user, dummy); - if (!registered) { - UserInfo info; - info.jid = user; - info.password = password; - m_storage->setUser(info); - } - else { - redirect_to(conn, hm, "/users?error=This+username+is+already+registered"); - return; - } - } - } - redirect_to(conn, hm, "/users?ok=1"); -} - -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; - Server:session *session = get_session(hm); - if (!session) { - std::string ok = get_http_var(hm, "ok"); - if (!ok.empty()) { - redirect_to(conn, hm, "/"); - return; - } - html += "

Register new Spectrum 2 master account

"; - } - else { - html += "

Spectrum 2 manager users

"; - - if (!session->admin) { - html += "

Only Spectrum 2 manager administrator can access this page.

"; - print_html(conn, hm, html); - return; - } - - html += "

Here, you can add new users who will have access to this web interface. " - "These users will be able to register new accounts on all Spectrum 2 instances " - "running on these server. They won't be able to change any Spectrum 2 instance " - "configuration influencing other users.

"; - } - - std::string error = get_http_var(hm, "error"); - if (!error.empty()) { - html += "

Error: " + error + "

"; - } - - if (!m_storage) { - print_html(conn, hm, html); - return; - } - - html += "
\ -

Register user \ - Register new user to Spectrum 2 manager web interface. \ -

\ - \ - \ - \ -

"; - std::vector users; - m_storage->getUsers(users); - - if (session) { - html += ""; - BOOST_FOREACH(std::string &user, users) { - html += ""; - html += ""; - html += ""; - html += ""; - } - html += "
UserAction
" + user + "Remove
"; - } - - print_html(conn, hm, html); -} - void Server::serve_oauth2(struct mg_connection *conn, struct http_message *hm) { std::cout << "OAUTH2 handler\n"; } diff --git a/spectrum_manager/src/server.h b/spectrum_manager/src/server.h index d7ccc981..8b9b03a9 100644 --- a/spectrum_manager/src/server.h +++ b/spectrum_manager/src/server.h @@ -66,9 +66,6 @@ class Server { std::string send_command(const std::string &jid, const std::string &cmd); private: - void serve_users(struct mg_connection *conn, struct http_message *hm); - void serve_users_add(struct mg_connection *conn, struct http_message *hm); - void serve_users_remove(struct mg_connection *conn, struct http_message *hm); void serve_logout(struct mg_connection *conn, struct http_message *hm); void serve_oauth2(struct mg_connection *conn, struct http_message *hm); void print_html(struct mg_connection *conn, struct http_message *hm, const std::string &html);