Change database table 'email_verification' to 'emailverification'. Add 'emailverification' to 'sql_tables'

This commit is contained in:
relesgoe 2020-09-01 21:17:34 -07:00
parent 07a67cd0a5
commit 28471b310f
5 changed files with 23 additions and 23 deletions

View file

@ -40,7 +40,7 @@
"acct_lastlogin_ip varchar(16)","NULL"
:"DROP INDEX username"
:"CREATE UNIQUE INDEX username2 ON ${prefix}BNET (username)"
[${prefix}email_verification]
[${prefix}emailverification]
"uid int NOT NULL PRIMARY KEY","'0'"
"code varchar(64)","NULL"
"expiration int", "'0'"

View file

@ -102,8 +102,8 @@ namespace pvpgn
}
/**
* If successful, sets "BNET\\acct\\email\\verified" attribute to true and sets "email_verification\\code"
* attribute and "email_verification\\expiration" attribute to 0 for the given account.
* If successful, sets "BNET\\acct\\email\\verified" attribute to true and sets "emailverification\\code"
* attribute and "emailverification\\expiration" attribute to 0 for the given account.
*/
AccountVerifyEmailStatus account_verify_email(t_account* account, const std::string& code)
{
@ -113,14 +113,14 @@ namespace pvpgn
return AccountVerifyEmailStatus::FailureOther;
}
const char* account_code = account_get_email_verification_code(account);
const char* account_code = account_get_emailverification_code(account);
if (account_code == nullptr)
{
eventlog(eventlog_level_error, __FUNCTION__, "Could not retrieve email verification code for account uid {}", account_get_uid(account));
return AccountVerifyEmailStatus::FailureOther;
}
unsigned int account_expiration = account_get_email_verification_expiration(account);
unsigned int account_expiration = account_get_emailverification_expiration(account);
if (account_expiration == 0)
{
eventlog(eventlog_level_error, __FUNCTION__, "Could not retrieve email verification expiration date for account uid {}", account_get_uid(account));
@ -146,8 +146,8 @@ namespace pvpgn
return AccountVerifyEmailStatus::FailureOther;
}
account_set_email_verification_code(account, "");
account_set_email_verification_expiration(account, 0);
account_set_emailverification_code(account, "");
account_set_emailverification_expiration(account, 0);
eventlog(eventlog_level_info, __FUNCTION__, "Succesfully verified email address ({}) account uid {}", account_get_email(account), account_get_uid(account));
@ -155,7 +155,7 @@ namespace pvpgn
}
/**
* Generates an email verification code and saves it in the "email_verification\\code" attribute for the given account. Sets the "email_verification\\expiration" attribute
* Generates an email verification code and saves it in the "emailverification\\code" attribute for the given account. Sets the "emailverification\\expiration" attribute
* to X minutes from current time, where X is the value of 'verify_account_email_expiration' in bnetd.conf.
* Sends an email containing the email verification code to the registered email address of the account.
*/
@ -174,8 +174,8 @@ namespace pvpgn
std::time_t expiration = now + (60ull * prefs_get_verify_account_email_expiration());
std::string code = fmt::to_string(uniform_dist(rengine));
int a = account_set_email_verification_expiration(account, expiration);
int b = account_set_email_verification_code(account, code.c_str());
int a = account_set_emailverification_expiration(account, expiration);
int b = account_set_emailverification_code(account, code.c_str());
if (!(a == 0 && b == 0))
{
eventlog(eventlog_level_error, __FUNCTION__, "Could not generate an email verification code for account uid {}", account_get_uid(account));

View file

@ -2665,7 +2665,7 @@ namespace pvpgn
return account_set_boolattr(account, "BNET\\acct\\email\\verified", is_verified ? 1 : 0);
}
extern char const * account_get_email_verification_code(t_account* account)
extern char const * account_get_emailverification_code(t_account* account)
{
if (account == nullptr)
{
@ -2673,10 +2673,10 @@ namespace pvpgn
return nullptr;
}
return account_get_strattr(account, "email_verification\\code");
return account_get_strattr(account, "emailverification\\code");
}
extern int account_set_email_verification_code(t_account* account, char const * verification_code)
extern int account_set_emailverification_code(t_account* account, char const * verification_code)
{
if (account == nullptr)
{
@ -2690,10 +2690,10 @@ namespace pvpgn
return -1;
}
return account_set_strattr(account, "email_verification\\code", verification_code);
return account_set_strattr(account, "emailverification\\code", verification_code);
}
extern unsigned int account_get_email_verification_expiration(t_account* account)
extern unsigned int account_get_emailverification_expiration(t_account* account)
{
if (account == nullptr)
{
@ -2701,10 +2701,10 @@ namespace pvpgn
return 0;
}
return account_get_numattr(account, "email_verification\\expiration");
return account_get_numattr(account, "emailverification\\expiration");
}
extern int account_set_email_verification_expiration(t_account* account, unsigned int expiration_date)
extern int account_set_emailverification_expiration(t_account* account, unsigned int expiration_date)
{
if (account == nullptr)
{
@ -2712,7 +2712,7 @@ namespace pvpgn
return -1;
}
return account_set_numattr(account, "email_verification\\expiration", expiration_date);
return account_set_numattr(account, "emailverification\\expiration", expiration_date);
}
extern int account_set_userlang(t_account * account, const char * lang)

View file

@ -266,10 +266,10 @@ namespace pvpgn
extern char const * account_get_email(t_account * account);
extern int account_get_email_verified(t_account* account);
extern int account_set_email_verified(t_account* account, bool is_verified);
extern char const* account_get_email_verification_code(t_account* account);
extern int account_set_email_verification_code(t_account* account, char const * verification_code);
extern unsigned int account_get_email_verification_expiration(t_account* account);
extern int account_set_email_verification_expiration(t_account* account, unsigned int expiration_date);
extern char const* account_get_emailverification_code(t_account* account);
extern int account_set_emailverification_code(t_account* account, char const * verification_code);
extern unsigned int account_get_emailverification_expiration(t_account* account);
extern int account_set_emailverification_expiration(t_account* account, unsigned int expiration_date);
extern int account_set_userlang(t_account * account, const char * lang);
extern int account_set_userlang(t_account * account, std::string lang);

View file

@ -67,7 +67,7 @@ namespace pvpgn
t_sql_engine *sql = NULL;
#ifndef SQL_ON_DEMAND
char const *sql_tables[] = { "BNET", "Record", "profile", "friend", "Team", NULL };
char const *sql_tables[] = { "BNET", "emailverification", "Record", "profile", "friend", "Team", NULL };
#endif /* SQL_ON_DEMAND */
const char* tab_prefix = SQL_DEFAULT_PREFIX;