created server code for registering user

This commit is contained in:
Václav Šmejkal 2024-09-01 20:08:01 +02:00
parent e8d60bc008
commit d6221da442
Signed by: ENGO150
GPG Key ID: 4A57E86482968843

View File

@ -590,6 +590,31 @@ void *why2_communicate_thread(void *arg)
continue; continue;
} }
//USER CONFIG
char *password = NULL;
char *user_config_path = why2_get_server_users_path();
if (!why2_toml_contains(user_config_path, decoded_buffer))
{
send_socket_deallocate(WHY2_CHAT_CODE_ENTER_PASSWORD, why2_chat_server_config("server_username"), connection);
if ((raw = read_user(connection, &raw_ptr)) == NULL) //READ
{
force_exiting = 1; //FAILURE
goto deallocation;
}
password = get_string_from_json_string(raw, "message"); //DECODE
why2_toml_write(user_config_path, username, password); //SAVE PASSWORD
}
//CLEANUP
why2_deallocate(user_config_path);
why2_deallocate(password);
why2_deallocate(raw);
//INFO
printf("User set username.\t%d\t%s\n", connection, decoded_buffer); printf("User set username.\t%d\t%s\n", connection, decoded_buffer);
} }
} }