mirror of
https://github.com/kunkundi/crossdesk-server.git
synced 2026-03-24 07:21:38 +08:00
[feat] generate unique ID for web clients without database storage
This commit is contained in:
@@ -165,7 +165,7 @@ std::string DeviceDBManager::GeneratePassword() {
|
||||
|
||||
DeviceCredential DeviceDBManager::AddDevice(const std::string& device_id,
|
||||
const std::string& password) {
|
||||
if (!device_id.empty()) {
|
||||
if (!device_id.empty() && device_id != "web") {
|
||||
const char* select_sql =
|
||||
"SELECT password_salt, password_hash FROM devices WHERE device_id = ?;";
|
||||
sqlite3_stmt* stmt = nullptr;
|
||||
@@ -215,7 +215,12 @@ DeviceCredential DeviceDBManager::AddDevice(const std::string& device_id,
|
||||
|
||||
// Device not exists or device_id is empty — generate new
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
std::string new_id = GenerateDeviceId();
|
||||
std::string new_id = device_id + "-" + GenerateDeviceId();
|
||||
|
||||
if(device_id == "web"){
|
||||
return {new_id, "", false};
|
||||
}
|
||||
|
||||
std::string new_pwd = GeneratePassword();
|
||||
|
||||
std::string salt = GenerateSalt();
|
||||
|
||||
Reference in New Issue
Block a user