Add enable/disable email setting in config
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"enabled": "false",
|
||||
"smtp": {
|
||||
"host":"",
|
||||
"port":"",
|
||||
|
||||
@@ -126,6 +126,7 @@ function toggleAccountServerLogoCommand(command, params, client) {
|
||||
function toggleAccountTwoFactorAuthCommand(command, params, client) {
|
||||
let flagValue = getAccountSettingsFlagValue("twoStepAuth");
|
||||
|
||||
if(getEmailConfig().enabled) {
|
||||
if(getPlayerData(client).accountData.emailAddress != "") {
|
||||
messagePlayerError(client, "You need to add your email to your account to use two-factor authentication.");
|
||||
messagePlayerTip(client, "[#FFFFFF]Use [#AAAAAA]/setemail [#FFFFFF]to add your email.");
|
||||
@@ -137,6 +138,7 @@ function toggleAccountTwoFactorAuthCommand(command, params, client) {
|
||||
messagePlayerTip(client, "[#FFFFFF]Use [#AAAAAA]/verifyemail [#FFFFFF]to verify your email.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(!doesPlayerHaveTwoFactorAuthEnabled(client)) {
|
||||
getPlayerData(client).accountData.settings = addBitFlag(getPlayerData(client).accountData.settings, flagValue);
|
||||
@@ -817,9 +819,11 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress
|
||||
showPlayerPromptGUI(client, "You have no characters. Would you like to make one?", "No Characters");
|
||||
getPlayerData(client).promptType = AG_PROMPT_CREATEFIRSTCHAR;
|
||||
|
||||
if(getEmailConfig().enabled) {
|
||||
let emailVerificationCode = generateEmailVerificationCode();
|
||||
setAccountEmailVerificationCode(getPlayerData(client).accountData, emailVerificationCode);
|
||||
sendEmailVerificationEmail(client, emailVerificationCode);
|
||||
}
|
||||
} else {
|
||||
messagePlayerAlert(client, `You have no characters. Use /newchar to make one.`);
|
||||
}
|
||||
|
||||
@@ -18,17 +18,17 @@ function initEmailScript() {
|
||||
|
||||
function sendEmail(toEmail, toName, subject, body) {
|
||||
module.smtp.send(
|
||||
emailConfig.smtp.host,
|
||||
emailConfig.smtp.port,
|
||||
emailConfig.smtp.useTLS,
|
||||
emailConfig.smtp.username,
|
||||
emailConfig.smtp.password,
|
||||
getEmailConfig().smtp.host,
|
||||
getEmailConfig().smtp.port,
|
||||
getEmailConfig().smtp.useTLS,
|
||||
getEmailConfig().smtp.username,
|
||||
getEmailConfig().smtp.password,
|
||||
toEmail,
|
||||
toName,
|
||||
subject,
|
||||
body,
|
||||
emailConfig.smtp.from,
|
||||
emailConfig.smtp.fromName);
|
||||
getEmailConfig().smtp.from,
|
||||
getEmailConfig().smtp.fromName);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
Reference in New Issue
Block a user