diff --git a/src/bnetd/command.cpp b/src/bnetd/command.cpp index 339c844..b847d22 100644 --- a/src/bnetd/command.cpp +++ b/src/bnetd/command.cpp @@ -5299,6 +5299,19 @@ namespace pvpgn account_set_email_verified(account, false); message_send_text(c, message_type_info, c, localize(c, "Email address successfully set to {}.", args[2])); + + if (prefs_get_verify_account_email() == 1) + { + bool send_verification_code_successful = account_generate_email_verification_code(account); + if (send_verification_code_successful) + { + message_send_text(c, message_type_info, c, localize(c, "An email has been sent, please check your inbox for the verification code.")); + } + else + { + message_send_text(c, message_type_error, c, localize(c, "An error has occurred, could not send a verification email.")); + } + } } else if (args[1] == "verify") { diff --git a/src/bnetd/handle_apireg.cpp b/src/bnetd/handle_apireg.cpp index f392bf7..681a29e 100644 --- a/src/bnetd/handle_apireg.cpp +++ b/src/bnetd/handle_apireg.cpp @@ -32,6 +32,7 @@ #include "compat/strcasecmp.h" +#include "account_email_verification.h" #include "prefs.h" #include "irc.h" #include "account.h" @@ -875,8 +876,15 @@ namespace pvpgn account_set_wol_apgar(tempacct, wol_pass_hash); if (apiregmember_get_email(apiregmember)) { - account_set_email_verified(tempacct, false); - account_set_email(tempacct, apiregmember_get_email(apiregmember)); + if (account_set_email(tempacct, apiregmember_get_email(apiregmember)) == 0) + { + account_set_email_verified(tempacct, false); + + if (prefs_get_verify_account_email() == 1) + { + account_generate_email_verification_code(account); + } + } } std::snprintf(message, sizeof(message), "Welcome in the amazing world of PvPGN! Your login can be used for all PvPGN Supported games!"); std::snprintf(hresult, sizeof(hresult), "0"); diff --git a/src/bnetd/handle_bnet.cpp b/src/bnetd/handle_bnet.cpp index 2bc3efe..a178db5 100644 --- a/src/bnetd/handle_bnet.cpp +++ b/src/bnetd/handle_bnet.cpp @@ -50,6 +50,7 @@ #include "common/bnetsrp3.h" #include "common/xstring.h" +#include "account_email_verification.h" #include "handlers.h" #include "connection.h" #include "prefs.h" @@ -5451,6 +5452,11 @@ namespace pvpgn { account_set_email_verified(account, false); eventlog(eventlog_level_info, __FUNCTION__, "[{}] init account \"{}\" email to \"{}\"", conn_get_socket(c), account_get_name(account), email); + + if (prefs_get_verify_account_email() == 1) + { + account_generate_email_verification_code(account); + } } return 0; } @@ -5499,6 +5505,11 @@ namespace pvpgn { account_set_email_verified(account, false); eventlog(eventlog_level_info, __FUNCTION__, "[{}] change account \"{}\" email to \"{}\"", conn_get_socket(c), account_get_name(account), newaddr); + + if (prefs_get_verify_account_email() == 1) + { + account_generate_email_verification_code(account); + } } return 0; }