implemented WHY2_MIN_USERNAME_LENGTH

This commit is contained in:
Václav Šmejkal 2024-01-27 22:19:38 +01:00
parent 1004b10a28
commit 73d0f64fc9
Signed by: ENGO150
GPG Key ID: 4A57E86482968843

View File

@ -403,7 +403,7 @@ void *why2_communicate_thread(void *arg)
decoded_buffer = get_string_from_json_string(raw, "message"); //DECODE decoded_buffer = get_string_from_json_string(raw, "message"); //DECODE
invalid_username = (strlen(decoded_buffer) > WHY2_MAX_USERNAME_LENGTH) || !check_username(decoded_buffer); //CHECK FOR USERNAMES LONGER THAN 20 CHARACTERS invalid_username = (strlen(decoded_buffer) > WHY2_MAX_USERNAME_LENGTH) || (strlen(decoded_buffer) < WHY2_MIN_USERNAME_LENGTH) || (!check_username(decoded_buffer)); //CHECK FOR USERNAMES LONGER THAN 20 CHARACTERS
why2_deallocate(username); why2_deallocate(username);
username = decoded_buffer; username = decoded_buffer;
@ -604,7 +604,7 @@ void *why2_listen_server(void *socket)
exiting = 1; //EXIT THIS THREAD exiting = 1; //EXIT THIS THREAD
} else if (strcmp(read + 8, WHY2_CHAT_CODE_PICK_USERNAME) == 0) //PICK USERNAME } else if (strcmp(read + 8, WHY2_CHAT_CODE_PICK_USERNAME) == 0) //PICK USERNAME
{ {
printf("%sEnter username (a-Z, 0-9; max %d characters):\n", WHY2_CLEAR_AND_GO_UP, WHY2_MAX_USERNAME_LENGTH); printf("%sEnter username (a-Z, 0-9; %d-%d characters):\n", WHY2_CLEAR_AND_GO_UP, WHY2_MAX_USERNAME_LENGTH, WHY2_MAX_USERNAME_LENGTH);
fflush(stdout); fflush(stdout);
goto continue_input; goto continue_input;