Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add password confirmation to account creation dialog, use the xbox task dialog during account creation request #760

Merged
merged 5 commits into from
Dec 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "stdafx.h"
#include "stdafx.h"
#include "screen_cartographer_account_manager.h"

#include "screen_cartographer_account_manager_strings.h"
Expand Down Expand Up @@ -45,6 +45,7 @@ enum e_cartographer_account_create_list_items : uint16
_item_cartographer_account_create_username = 0,
_item_cartographer_account_create_email,
_item_cartographer_account_create_password,
_item_cartographer_account_create_confirm_password,
_item_cartographer_account_create_process,

k_total_no_of_cartographer_account_create_list_items,
Expand All @@ -60,6 +61,7 @@ enum e_cartographer_screen_type_account_create_string_table
_screen_type_account_create_button_placeholder_username_text = k_screen_type_account_list_button_text_index,
_screen_type_account_create_button_placeholder_email_text,
_screen_type_account_create_button_placeholder_password_text,
_screen_type_account_create_button_placeholder_confirm_password_text,
_screen_type_account_create_button_create_account,

k_screen_type_account_create_unknown_text
Expand Down Expand Up @@ -96,6 +98,7 @@ struct s_cartographer_account_create_data
char user_name[XUSER_NAME_SIZE];
char email[128];
char password[128];
e_cartographer_error_id server_error_code;
};

struct s_cartographer_account_login_data
Expand Down Expand Up @@ -137,7 +140,7 @@ const wchar_t*** k_screen_label_table[k_language_count] =
/* prototypes */

void* ui_load_cartographer_invalid_login_token(void);
void xbox_live_task_progress_callback(c_screen_xbox_live_task_progress_dialog* dialog);
void sign_in_xbox_task_progress_cb(c_screen_xbox_live_task_progress_dialog* dialog);
DWORD WINAPI thread_account_login_proc_cb(LPVOID lParam);
static DWORD WINAPI thread_account_create_proc_cb(LPVOID lParam);
static const wchar_t* get_cartographer_account_manager_label(e_cartographer_account_manager_screen_type screen_type, int32 label_id);
Expand Down Expand Up @@ -183,7 +186,7 @@ c_cartographer_account_manager_edit_list::c_cartographer_account_manager_edit_li

linker_type2.link(&this->m_slot_2);

const wchar_t* placeholder_username, *placeholder_email, *placeholder_password;
const wchar_t* placeholder_username, *placeholder_email, *placeholder_password, *placeholder_confirm_password;
switch (m_cartographer_screen_type)
{
case _cartographer_account_manager_screen_type_none:
Expand All @@ -197,9 +200,11 @@ c_cartographer_account_manager_edit_list::c_cartographer_account_manager_edit_li
placeholder_username = get_cartographer_account_manager_label(m_cartographer_screen_type, _screen_type_account_create_button_placeholder_username_text);
placeholder_email = get_cartographer_account_manager_label(m_cartographer_screen_type, _screen_type_account_create_button_placeholder_email_text);
placeholder_password = get_cartographer_account_manager_label(m_cartographer_screen_type, _screen_type_account_create_button_placeholder_password_text);
placeholder_confirm_password = get_cartographer_account_manager_label(m_cartographer_screen_type, _screen_type_account_create_button_placeholder_confirm_password_text);
wcsncpy(m_account_create.user_name, placeholder_username, XUSER_NAME_SIZE);
wcsncpy(m_account_create.email, placeholder_email, ARRAYSIZE(m_account_create.email));
wcsncpy(m_account_create.password, placeholder_password, ARRAYSIZE(m_account_create.password));
wcsncpy(m_account_create.password_confirmation, placeholder_confirm_password, ARRAYSIZE(m_account_create.password_confirmation));
break;
case _cartographer_account_manager_screen_type_add_account:
csmemset(&m_account_add, 0, sizeof(m_account_add));
Expand Down Expand Up @@ -318,6 +323,9 @@ void c_cartographer_account_manager_edit_list::update_list_items(c_list_item_wid
case _screen_type_account_create_button_placeholder_password_text:
button_label = cartographer_account_manager_set_password_label(m_account_create.password, password_censored_buffer_wide);
break;
case _screen_type_account_create_button_placeholder_confirm_password_text:
button_label = cartographer_account_manager_set_password_label(m_account_create.password_confirmation, password_censored_buffer_wide);
break;
default:
button_label = get_cartographer_account_manager_label(m_cartographer_screen_type, k_screen_type_account_create_button_text_index + list_item_index);
break;
Expand Down Expand Up @@ -401,9 +409,10 @@ void c_cartographer_account_manager_edit_list::handle_item_pressed_event_for_add
c_cartographer_account_manager_menu::update_accounting_active_handle(true);
snprintf(g_account_add_login_data.email_or_username, ARRAYSIZE(g_account_add_login_data.email_or_username), "%S", m_account_add.email_or_username);
snprintf(g_account_add_login_data.password, ARRAYSIZE(g_account_add_login_data.password), "%S", m_account_add.password);

g_account_manager_login_thread_handle = CreateThread(NULL, 0, thread_account_login_proc_cb, (LPVOID)NONE, 0, NULL);
c_screen_xbox_live_task_progress_dialog::add_task(sign_in_xbox_task_progress_cb);

c_screen_xbox_live_task_progress_dialog::add_task(xbox_live_task_progress_callback);
user_interface_back_out_from_channel(parent_screen_ui_channel, parent_render_window);
}
}
Expand Down Expand Up @@ -452,8 +461,10 @@ void c_cartographer_account_manager_edit_list::handle_item_pressed_event_for_lis
{
c_cartographer_account_manager_menu::g_accounting_go_back_to_list = false;
c_cartographer_account_manager_menu::update_accounting_active_handle(true);

g_account_manager_login_thread_handle = CreateThread(NULL, 0, thread_account_login_proc_cb, (LPVOID)button_id, 0, NULL);
c_screen_xbox_live_task_progress_dialog::add_task(xbox_live_task_progress_callback);
c_screen_xbox_live_task_progress_dialog::add_task(sign_in_xbox_task_progress_cb);

user_interface_back_out_from_channel(parent_screen_ui_channel, parent_render_window);
}
}
Expand All @@ -480,6 +491,22 @@ void c_cartographer_account_manager_edit_list::handle_item_pressed_event_for_lis
}


void __cdecl create_account_xbox_task_progress_cb(c_screen_xbox_live_task_progress_dialog* dialog)
{
dialog->set_display_text_raw(L"Processing account creation request, please wait...");

if (g_account_manager_thread_handle == NULL)
{
dialog->close_task();
c_cartographer_error_menu::load_by_error_id(g_account_create_data.server_error_code);

SecureZeroMemory(g_account_create_data.user_name, sizeof(g_account_create_data.user_name));
SecureZeroMemory(g_account_create_data.email, sizeof(g_account_create_data.email));
SecureZeroMemory(g_account_create_data.password, sizeof(g_account_create_data.password));
memset(&g_account_create_data, 0, sizeof(g_account_create_data));
}
}

void c_cartographer_account_manager_edit_list::handle_item_pressed_event_for_create_account(s_event_record* event_record, int32* a3)
{
const int32 button_id = DATUM_INDEX_TO_ABSOLUTE_INDEX(*a3);
Expand All @@ -489,7 +516,7 @@ void c_cartographer_account_manager_edit_list::handle_item_pressed_event_for_cre

if (button_id == _item_cartographer_account_create_username)
{
ui_load_virtual_keyboard(m_account_create.user_name, ARRAYSIZE(m_account_create.user_name) /* Wide string buffer size */, _vkbd_custom_context_username);
ui_load_virtual_keyboard(m_account_create.user_name, /* wide characters count */ ARRAYSIZE(m_account_create.user_name), _vkbd_custom_context_username);
}
else if (button_id == _item_cartographer_account_create_email)
{
Expand All @@ -499,9 +526,17 @@ void c_cartographer_account_manager_edit_list::handle_item_pressed_event_for_cre
{
ui_load_virtual_keyboard(m_account_create.password, ARRAYSIZE(m_account_create.password), _vkbd_custom_context_password);
}
else if (button_id == _item_cartographer_account_create_confirm_password)
{
ui_load_virtual_keyboard(m_account_create.password_confirmation, ARRAYSIZE(m_account_create.password_confirmation), _vkbd_custom_context_password);
}
else if (button_id == _item_cartographer_account_create_process)
{
if (g_account_manager_thread_handle == NULL)
if (ustrncmp(m_account_create.password, m_account_create.password_confirmation, k_cartographer_account_email_and_password_max_length) != 0)
{
c_cartographer_error_menu::load_by_error_id(_cartographer_error_id_account_create_password_confirmation_mismatch);
}
else if (g_account_manager_thread_handle == NULL)
{
c_cartographer_account_manager_menu::g_accounting_go_back_to_list = false;
c_cartographer_account_manager_menu::update_accounting_active_handle(true);
Expand All @@ -510,11 +545,14 @@ void c_cartographer_account_manager_edit_list::handle_item_pressed_event_for_cre
snprintf(g_account_create_data.email, ARRAYSIZE(g_account_create_data.email), "%S", m_account_create.email);
snprintf(g_account_create_data.password, ARRAYSIZE(g_account_create_data.password), "%S", m_account_create.password);

g_account_manager_login_thread_handle = CreateThread(NULL, 0, thread_account_login_proc_cb, (LPVOID)NONE, 0, NULL);
SecureZeroMemory(m_account_create.user_name, sizeof(m_account_create.user_name));
SecureZeroMemory(m_account_create.email, sizeof(m_account_create.email));
SecureZeroMemory(m_account_create.password, sizeof(m_account_create.password));
SecureZeroMemory(m_account_create.password_confirmation, sizeof(m_account_create.password_confirmation));

user_interface_back_out_from_channel(parent_screen_ui_channel, parent_render_window);
c_cartographer_error_menu::load_by_error_id(_cartographer_error_id_account_create_processing_account_notice);
g_account_manager_thread_handle = CreateThread(NULL, 0, thread_account_create_proc_cb, (LPVOID)0, 0, NULL);
c_screen_xbox_live_task_progress_dialog::add_task(create_account_xbox_task_progress_cb);
}
}
return;
Expand All @@ -539,6 +577,7 @@ void c_cartographer_account_manager_menu::pre_destroy()
if (c_cartographer_account_manager_menu::g_accounting_go_back_to_list
&& c_cartographer_account_manager_menu::is_accounting_active_handle())
{
load_for_account_list_context();
c_cartographer_account_manager_menu::g_accounting_go_back_to_list = false;
}
break;
Expand All @@ -547,6 +586,7 @@ void c_cartographer_account_manager_menu::pre_destroy()
if (c_cartographer_account_manager_menu::g_accounting_go_back_to_list
&& c_cartographer_account_manager_menu::is_accounting_active_handle())
{
load_for_account_list_context();
c_cartographer_account_manager_menu::g_accounting_go_back_to_list = false;
}
break;
Expand Down Expand Up @@ -650,7 +690,7 @@ void* __cdecl c_cartographer_account_manager_menu::load(s_screen_parameters* par
selected_button_index = 0;
break;
case _cartographer_account_manager_screen_type_create_account:
button_count = 4;
button_count = 5;
selected_button_index = 0;
c_cartographer_account_manager_menu::g_accounting_go_back_to_list = true;
break;
Expand Down Expand Up @@ -732,7 +772,7 @@ void* ui_load_cartographer_invalid_login_token(void)
}


void xbox_live_task_progress_callback(c_screen_xbox_live_task_progress_dialog* dialog)
void sign_in_xbox_task_progress_cb(c_screen_xbox_live_task_progress_dialog* dialog)
{
dialog->set_display_text_raw(L"Signing into Project Cartographer, please wait...");

Expand Down Expand Up @@ -858,13 +898,8 @@ static DWORD WINAPI thread_account_create_proc_cb(LPVOID lParam)
Sleep(200L);

//submit account creation.
if (HandleGuiAccountCreate(g_account_create_data.user_name, g_account_create_data.email, g_account_create_data.password))
if (HandleGuiAccountCreate(g_account_create_data.user_name, g_account_create_data.email, g_account_create_data.password, &g_account_create_data.server_error_code))
{
c_cartographer_error_menu::load_by_error_id(_cartographer_error_id_account_create_verification_email_sent);

SecureZeroMemory(g_account_create_data.user_name, sizeof(g_account_create_data.user_name));
SecureZeroMemory(g_account_create_data.email, sizeof(g_account_create_data.email));
SecureZeroMemory(g_account_create_data.password, sizeof(g_account_create_data.password));
}

c_cartographer_account_manager_menu::update_accounting_active_handle(false);
Expand All @@ -879,24 +914,37 @@ static const wchar_t* get_cartographer_account_manager_label(e_cartographer_acco
return k_screen_label_table[language][screen_type][label_id];
}

static const wchar_t* cartographer_account_manager_set_password_label(const wchar_t* password, wchar_t* password_censored_buffer)
static const wchar_t* cartographer_account_manager_set_password_label(const wchar_t* password, wchar_t* password_censored_text)
{
const wchar_t* default_password_label = get_cartographer_account_manager_label(_cartographer_account_manager_screen_type_create_account, _screen_type_account_create_button_placeholder_password_text);
const size_t default_password_label_length = ustrnlen(default_password_label, k_cartographer_account_email_and_password_max_length);
const wchar_t* default_password_labels[2];
default_password_labels[0] = get_cartographer_account_manager_label(_cartographer_account_manager_screen_type_create_account, _screen_type_account_create_button_placeholder_password_text);
default_password_labels[1] = get_cartographer_account_manager_label(_cartographer_account_manager_screen_type_create_account, _screen_type_account_create_button_placeholder_confirm_password_text);

bool is_default_password_label = false;
for (int32 i = 0; i < ARRAYSIZE(default_password_labels); i++)
{
const size_t default_password_label_length = wcslen(default_password_labels[i]);

// Check if the password passed is the default password level (k_password_string)
const bool is_not_default_password_label = ustrncmp(password, default_password_label, default_password_label_length) != 0;
if (is_not_default_password_label)
// Check if the password passed is the default password level (k_password_string)
is_default_password_label = ustrncmp(password, default_password_labels[i], default_password_label_length) == 0;
if (is_default_password_label)
{
break;
}
}

if (!is_default_password_label)
{
// Populate password_censored_buffer with the '*' character for each character entered
// Populate password_censored_text with the '*' character for each character entered
const size_t length = ustrnlen(password, k_cartographer_account_email_and_password_max_length);
size_t i = 0;

size_t i = 0;
for (; i < length; ++i)
{
password_censored_buffer[i] = L'*';
password_censored_text[i] = L'*';
}
password_censored_buffer[i] = L'\0';
password_censored_text[i] = L'\0';
}
return is_not_default_password_label ? password_censored_buffer : password;

return is_default_password_label ? password : password_censored_text;
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class c_cartographer_account_manager_edit_list : public c_list_widget
wchar_t user_name[XUSER_NAME_SIZE];
wchar_t email[k_cartographer_account_email_and_password_max_length];
wchar_t password[k_cartographer_account_email_and_password_max_length];
wchar_t password_confirmation[k_cartographer_account_email_and_password_max_length];
} m_account_create;

struct
Expand Down Expand Up @@ -109,8 +110,6 @@ class c_cartographer_account_manager_menu : protected c_screen_with_menu
static c_cartographer_account_manager_menu* load_for_account_list_context(void);
static c_cartographer_account_manager_menu* load_for_account_remove_from_list_context(void);



// c_cartographer_account_manager_menu virtual functions

virtual ~c_cartographer_account_manager_menu(void) = default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

const wchar_t k_username_string_eng[] = L"[Username]";
const wchar_t k_password_string_eng[] = L"[Password]";
const wchar_t k_password_confirm_string_eng[] = L"[Confirm Password]";
const wchar_t k_remember_me_string_eng[] = L"%c Remember me";

const wchar_t* k_screen_type_list_add_account_eng[] =
Expand Down Expand Up @@ -37,6 +38,7 @@ static const wchar_t* k_screen_type_list_create_account_eng[] =
k_username_string_eng,
L"[Email]",
k_password_string_eng,
k_password_confirm_string_eng,
L"Create Account",
L"<unknown label>"
};
46 changes: 31 additions & 15 deletions xlive/Blam/Engine/interface/screens/screen_cartographer_errors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ const s_cartographer_error_globals k_cartographer_error_globals[k_language_count
L"Username Taken!",
L"The Username you have entered is already in use!"
},
{
L"Password mismatch!",
L"Password confirmation does not match the actual password!"
},
{
L"BANNED Email Provider!",
L"The Email Address you have entered is using a domain name that has been banned! We do not allow disposable email addresses! If this is a mistake please contact an admin."
Expand Down Expand Up @@ -127,9 +131,21 @@ void c_cartographer_error_menu::get_error_label(e_cartographer_error_id error_id

void* c_cartographer_error_menu::load_by_error_id(e_cartographer_error_id error_id) {

c_cartographer_error_menu* error_menu = (c_cartographer_error_menu*)ui_custom_cartographer_load_menu(c_cartographer_error_menu::load, 1);
error_menu->m_error_id = error_id;
s_screen_parameters params;
c_cartographer_error_menu* error_menu = NULL;

params.m_flags = 0;
params.m_window_index = _window_4;
params.m_context = NULL;
params.user_flags = user_interface_controller_get_signed_in_controllers_mask() | FLAG(k_windows_device_controller_index);
params.m_channel_type = _user_interface_channel_type_game_error;
params.m_screen_state.field_0 = NONE;
params.m_screen_state.m_last_focused_item_order = NONE;
params.m_screen_state.m_last_focused_item_index = NONE;
params.m_load_function = c_cartographer_error_menu::load;
error_menu = (c_cartographer_error_menu*)params.m_load_function(&params);

error_menu->m_error_id = error_id;
return error_menu;
}

Expand All @@ -147,7 +163,7 @@ void* c_cartographer_error_menu::load(s_screen_parameters* parameters)


c_cartographer_error_menu::c_cartographer_error_menu(e_user_interface_channel_type _ui_channel, e_user_interface_render_window _window_index, uint16 _flags) :
c_screen_widget(_screen_error_dialog_ok_cancel, _ui_channel, _window_index, _flags)
c_screen_widget(_screen_error_dialog_ok, _ui_channel, _window_index, _flags)
{
m_error_id = _cartpgrapher_error_id_none;
}
Expand All @@ -172,20 +188,21 @@ void c_cartographer_error_menu::pre_destroy()

bool c_cartographer_error_menu::handle_event(s_event_record* event)
{
if (event->type == _user_interface_event_type_gamepad_button_pressed)
bool result = false;
if (event->type == _user_interface_event_type_keyboard_button_pressed
|| event->type == _user_interface_event_type_gamepad_button_pressed
|| event->type == _user_interface_event_type_mouse_button_left_click)
{
if (event->component == _user_interface_controller_component_button_a
|| event->component == _user_interface_controller_component_button_b
|| event->component == _user_interface_controller_component_button_start
|| event->component == _user_interface_controller_component_button_back)
if (event->component == _user_interface_keyboard_component_button_letter_a
|| event->component == _user_interface_controller_component_button_a)
{
e_user_interface_render_window parent_render_window = this->get_parent_render_window();
e_user_interface_channel_type parent_screen_ui_channel = this->get_parent_channel();

user_interface_back_out_from_channel(parent_screen_ui_channel, parent_render_window);
start_widget_animation(3);
result = true;
}
}
return c_screen_widget::handle_event(event);;

//return c_screen_widget::handle_event(event);
return result;
}

void c_cartographer_error_menu::initialize(s_screen_parameters* screen_parameters)
Expand All @@ -194,7 +211,6 @@ void c_cartographer_error_menu::initialize(s_screen_parameters* screen_parameter
csmemset(&layout, 0, sizeof(layout));
layout.panes_count = 1;


datum widget_tag_datum = user_interface_get_widget_tag_index_from_screen_id(this->m_screen_id);
if (widget_tag_datum != NONE)
{
Expand All @@ -213,7 +229,7 @@ void c_cartographer_error_menu::initialize(s_screen_parameters* screen_parameter
}

m_header_text.set_text(header_text);
c_text_widget* subheader_text_widget = try_find_text_widget(K_SUB_HEADER_TEXT_BLOCK_INDEX);
c_text_widget* subheader_text_widget = try_find_text_widget(k_sub_header_text_block_index);
if (subheader_text_widget)
{
subheader_text_widget->set_text(subheader_text);
Expand Down
Loading