mirror of
https://github.com/kunkundi/crossdesk-server.git
synced 2026-03-24 15:29:55 +08:00
[feat] generate and modify id/password supported
This commit is contained in:
@@ -156,7 +156,12 @@ void SignalServer::on_message(websocketpp::connection_hdl hdl,
|
||||
switch (HASH_STRING_PIECE(type.c_str())) {
|
||||
case "login"_H: {
|
||||
std::string host_id = j["user_id"].get<std::string>();
|
||||
std::string password = j["password"].get<std::string>();
|
||||
std::string password;
|
||||
if (j.contains("password")) {
|
||||
password = j["password"].get<std::string>();
|
||||
} else {
|
||||
password = "";
|
||||
}
|
||||
|
||||
DeviceCredential dev_cred =
|
||||
device_db_manager_->AddDevice(host_id, password);
|
||||
@@ -174,7 +179,8 @@ void SignalServer::on_message(websocketpp::connection_hdl hdl,
|
||||
|
||||
bool success = true;
|
||||
if (register_success) {
|
||||
LOG_INFO("New client, assign id [{}] to it", ret_host_id);
|
||||
LOG_INFO("New client, assign id [{}:{}] to it", ret_host_id,
|
||||
ret_password);
|
||||
success = transmission_manager_.BindUserToWsHandle(ret_host_id, hdl);
|
||||
} else if (login_success) {
|
||||
LOG_INFO("Receive login request with id [{}]", host_id);
|
||||
@@ -186,13 +192,13 @@ void SignalServer::on_message(websocketpp::connection_hdl hdl,
|
||||
if (success) {
|
||||
json message = {{"type", "login"},
|
||||
{"user_id", ret_host_id},
|
||||
{"pasword", ret_password},
|
||||
{"password", ret_password},
|
||||
{"status", "success"}};
|
||||
send_msg(hdl, message);
|
||||
} else {
|
||||
json message = {{"type", "login"},
|
||||
{"user_id", ret_host_id},
|
||||
{"pasword", ret_password},
|
||||
{"password", ret_password},
|
||||
{"status", "fail"}};
|
||||
send_msg(hdl, message);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ set_languages("c++17")
|
||||
|
||||
add_rules("mode.release", "mode.debug")
|
||||
|
||||
add_requires("asio 1.24.0", "nlohmann_json", "spdlog 1.14.1", "sqlite3 3.49.0", "openssl")
|
||||
add_requires("asio 1.24.0", "nlohmann_json 3.11.3", "spdlog 1.14.1", "sqlite3 3.49.0", "openssl 1.1.1-w")
|
||||
|
||||
add_defines("ASIO_STANDALONE", "ASIO_HAS_STD_TYPE_TRAITS",
|
||||
"ASIO_HAS_STD_SHARED_PTR", "ASIO_HAS_STD_ADDRESSOF", "ASIO_HAS_STD_ATOMIC",
|
||||
|
||||
Reference in New Issue
Block a user