If account email verification is enabled, automatically send verification email whenever an email is set/changed

This commit is contained in:
relesgoe 2020-08-08 10:12:19 -07:00
parent 930838484c
commit 8e2aa1f129
3 changed files with 34 additions and 2 deletions

View file

@ -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")
{

View file

@ -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");

View file

@ -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;
}