Add enable/disable email setting in config

This commit is contained in:
Vortrex
2021-05-10 07:37:46 -05:00
parent e1b5f32563
commit 380e7334a5
3 changed files with 24 additions and 19 deletions

View File

@@ -1,4 +1,5 @@
{ {
"enabled": "false",
"smtp": { "smtp": {
"host":"", "host":"",
"port":"", "port":"",

View File

@@ -126,16 +126,18 @@ function toggleAccountServerLogoCommand(command, params, client) {
function toggleAccountTwoFactorAuthCommand(command, params, client) { function toggleAccountTwoFactorAuthCommand(command, params, client) {
let flagValue = getAccountSettingsFlagValue("twoStepAuth"); let flagValue = getAccountSettingsFlagValue("twoStepAuth");
if(getPlayerData(client).accountData.emailAddress != "") { if(getEmailConfig().enabled) {
messagePlayerError(client, "You need to add your email to your account to use two-factor authentication."); if(getPlayerData(client).accountData.emailAddress != "") {
messagePlayerTip(client, "[#FFFFFF]Use [#AAAAAA]/setemail [#FFFFFF]to add your email."); messagePlayerError(client, "You need to add your email to your account to use two-factor authentication.");
return false; messagePlayerTip(client, "[#FFFFFF]Use [#AAAAAA]/setemail [#FFFFFF]to add your email.");
} return false;
}
if(isAccountEmailVerified(getPlayerData(client).accountData)) { if(isAccountEmailVerified(getPlayerData(client).accountData)) {
messagePlayerError(client, "You need to verify your email to your account to use two-factor authentication."); messagePlayerError(client, "You need to verify your email to your account to use two-factor authentication.");
messagePlayerTip(client, "[#FFFFFF]Use [#AAAAAA]/verifyemail [#FFFFFF]to verify your email."); messagePlayerTip(client, "[#FFFFFF]Use [#AAAAAA]/verifyemail [#FFFFFF]to verify your email.");
return false; return false;
}
} }
if(!doesPlayerHaveTwoFactorAuthEnabled(client)) { if(!doesPlayerHaveTwoFactorAuthEnabled(client)) {
@@ -817,9 +819,11 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress
showPlayerPromptGUI(client, "You have no characters. Would you like to make one?", "No Characters"); showPlayerPromptGUI(client, "You have no characters. Would you like to make one?", "No Characters");
getPlayerData(client).promptType = AG_PROMPT_CREATEFIRSTCHAR; getPlayerData(client).promptType = AG_PROMPT_CREATEFIRSTCHAR;
let emailVerificationCode = generateEmailVerificationCode(); if(getEmailConfig().enabled) {
setAccountEmailVerificationCode(getPlayerData(client).accountData, emailVerificationCode); let emailVerificationCode = generateEmailVerificationCode();
sendEmailVerificationEmail(client, emailVerificationCode); setAccountEmailVerificationCode(getPlayerData(client).accountData, emailVerificationCode);
sendEmailVerificationEmail(client, emailVerificationCode);
}
} else { } else {
messagePlayerAlert(client, `You have no characters. Use /newchar to make one.`); messagePlayerAlert(client, `You have no characters. Use /newchar to make one.`);
} }

View File

@@ -18,17 +18,17 @@ function initEmailScript() {
function sendEmail(toEmail, toName, subject, body) { function sendEmail(toEmail, toName, subject, body) {
module.smtp.send( module.smtp.send(
emailConfig.smtp.host, getEmailConfig().smtp.host,
emailConfig.smtp.port, getEmailConfig().smtp.port,
emailConfig.smtp.useTLS, getEmailConfig().smtp.useTLS,
emailConfig.smtp.username, getEmailConfig().smtp.username,
emailConfig.smtp.password, getEmailConfig().smtp.password,
toEmail, toEmail,
toName, toName,
subject, subject,
body, body,
emailConfig.smtp.from, getEmailConfig().smtp.from,
emailConfig.smtp.fromName); getEmailConfig().smtp.fromName);
} }
// =========================================================================== // ===========================================================================