Skip to content

Commit

Permalink
New Email Status Added
Browse files Browse the repository at this point in the history
Update for #757. Added New Email status and email verifcation check for new email.

Partially added new require_user_email config option.
  • Loading branch information
eSilverStrike committed Dec 27, 2017
1 parent 9a6c60d commit 2f772df
Show file tree
Hide file tree
Showing 17 changed files with 331 additions and 39 deletions.
22 changes: 16 additions & 6 deletions language/english.php
Expand Up @@ -449,7 +449,14 @@
'tfa_download' => 'Download Backup Codes',
'tfa_new_backup_code' => 'Generate a new set of backup codes',
'tfa_generate_confirm' => 'Go ahead?',
'desc_new_pwd_status' => 'You are required to enter a new password for your account. You can enter a new password for your account below. <em>Please note you will not be able to do anything with your account until your password is updated.</em>'
'desc_new_pwd_status' => 'You are required to enter a new password for your account. You can enter a new password for your account below. <em>Please note you will not be able to do anything with your account until your password is updated.</em>',
'new_email' => 'New Email',
'set_new_email' => 'Set New Email',
'confirm_new_email' => 'Confirm new email',
'enter_new_email' => 'Enter New Email',
'desc_new_email_status' => 'You are required to enter a new email address for your account. You can enter a new email for your account below. <em>Please note you will not be able to do anything with your account until your email is updated and verified.</em>',
'email_msg_email_status_1' => "You have updated your email address for your account \"%s\" on {$_CONF['site_name']}, <{$_CONF['site_url']}>.\n\nPlease click on the following link to verify this email address:\n\n",
'email_msg_email_status_2' => "If you do not verify this email address and you log into your account you will be required to enter a new email address and go through this email verification process again.\n\n"
);

###############################################################################
Expand Down Expand Up @@ -1469,10 +1476,10 @@
20 => '',
21 => 'The user has been successfully saved.',
22 => 'The user has been successfully deleted.',
23 => '',
24 => '',
25 => '',
26 => '',
23 => 'Your passwords must match, please try again.',
24 => 'Your emails must match, please try again.',
25 => 'You have not entered a valid email address, please try again.',
26 => 'That email address is already being used by an account, please try again.',
27 => 'Message successfully sent.',
28 => 'The plugin has been successfully saved',
29 => 'Sorry, you do not have access to this administration page. Please note that all attempts to access unauthorized features are logged',
Expand Down Expand Up @@ -1576,7 +1583,9 @@
153 => 'You last emailed an article %1$d seconds ago. This site requires at least %2$d seconds between emailing articles.',
400 => 'Not all required fields have been passed validation', // Error codes in the 400 range reserved for CUSTOM membership
401 => 'Please enter Fullname',
500 => 'The Data, Template, Resource, and File Manager Cache has been successfully cleared.'
501 => 'A verification message has been sent to your email address. Please click on the link in the email to confirm your email address and update your account. If you log into your account again before you verify your email address you will be asked again for a email address.<br' . XHTML . '><br' . XHTML . '>Please note you have now been successfully logged out so you can complete this verification.',
502 => 'Your request for a new email has expired. Please try again below.',
503 => 'Your email has been successfully verified. Please login now.'
);

###############################################################################
Expand Down Expand Up @@ -2111,6 +2120,7 @@
'hide_author_exclusion' => "Allow Hide Author",
'show_fullname' => "Show Fullname",
'show_servicename' => "Show Service Name",
'require_user_email' => "Require User Email",
'custom_registration' => "Enable Custom Registration",
'user_login_method' => "User Login Method",
'facebook_login' => "Enable OAuth Login Method Facebook",
Expand Down
23 changes: 17 additions & 6 deletions language/english_utf-8.php
Expand Up @@ -449,7 +449,14 @@
'tfa_download' => 'Download Backup Codes',
'tfa_new_backup_code' => 'Generate a new set of backup codes',
'tfa_generate_confirm' => 'Go ahead?',
'desc_new_pwd_status' => 'You are required to enter a new password for your account. You can enter a new password for your account below. <em>Please note you will not be able to do anything with your account until your password is updated.</em>'
'desc_new_pwd_status' => 'You are required to enter a new password for your account. You can enter a new password for your account below. <em>Please note you will not be able to do anything with your account until your password is updated.</em>',
'new_email' => 'New Email',
'set_new_email' => 'Set New Email',
'confirm_new_email' => 'Confirm new email',
'enter_new_email' => 'Enter New Email',
'desc_new_email_status' => 'You are required to enter a new email address for your account. You can enter a new email for your account below. <em>Please note you will not be able to do anything with your account until your email is updated and verified.</em>',
'email_msg_email_status_1' => "You have updated your email address for your account \"%s\" on {$_CONF['site_name']}, <{$_CONF['site_url']}>.\n\nPlease click on the following link to verify this email address:\n\n",
'email_msg_email_status_2' => "If you do not verify this email address and you log into your account you will be required to enter a new email address and go through this email verification process again.\n\n"
);

###############################################################################
Expand Down Expand Up @@ -1470,10 +1477,10 @@
20 => '',
21 => 'The user has been successfully saved.',
22 => 'The user has been successfully deleted.',
23 => '',
24 => '',
25 => '',
26 => '',
23 => 'Your passwords must match, please try again.',
24 => 'Your emails must match, please try again.',
25 => 'You have not entered a valid email address, please try again.',
26 => 'That email address is already being used by an account, please try again.',
27 => 'Message successfully sent.',
28 => 'The plugin has been successfully saved',
29 => 'Sorry, you do not have access to this administration page. Please note that all attempts to access unauthorized features are logged.',
Expand Down Expand Up @@ -1577,7 +1584,10 @@
153 => 'You last emailed an article %1$d seconds ago. This site requires at least %2$d seconds between emailing articles.',
400 => 'Not all required fields have been passed validation', // Error codes in the 400 range reserved for CUSTOM membership
401 => 'Please enter Fullname',
500 => 'The Data, Template, Resource, and File Manager Cache has been successfully cleared.'
500 => 'The Data, Template, Resource, and File Manager Cache has been successfully cleared.',
501 => 'A verification message has been sent to your email address. Please click on the link in the email to confirm your email address and update your account. If you log into your account again before you verify your email address you will be asked again for a email address.<br' . XHTML . '><br' . XHTML . '>Please note you have now been successfully logged out so you can complete this verification.',
502 => 'Your request for a new email has expired. Please try again below.',
503 => 'Your email has been successfully verified. Please login now.'
);

###############################################################################
Expand Down Expand Up @@ -2112,6 +2122,7 @@
'hide_author_exclusion' => "Allow Hide Author",
'show_fullname' => "Show Fullname",
'show_servicename' => "Show Service Name",
'require_user_email' => "Require User Email",
'custom_registration' => "Enable Custom Registration",
'user_login_method' => "User Login Method",
'facebook_login' => "Enable OAuth Login Method Facebook",
Expand Down
23 changes: 17 additions & 6 deletions language/japanese_utf-8.php
Expand Up @@ -457,7 +457,14 @@
'tfa_download' => 'バックアップコードをダウンロード',
'tfa_new_backup_code' => 'バックアップコードを生成し直す',
'tfa_generate_confirm' => '実行してもよいですか?',
'desc_new_pwd_status' => 'You are required to enter a new password for your account. You can enter a new password for your account below. <em>Please note you will not be able to do anything with your account until your password is updated.</em>'
'desc_new_pwd_status' => 'You are required to enter a new password for your account. You can enter a new password for your account below. <em>Please note you will not be able to do anything with your account until your password is updated.</em>',
'new_email' => 'New Email',
'set_new_email' => 'Set New Email',
'confirm_new_email' => 'Confirm new email',
'enter_new_email' => 'Enter New Email',
'desc_new_email_status' => 'You are required to enter a new email address for your account. You can enter a new email for your account below. <em>Please note you will not be able to do anything with your account until your email is updated and verified.</em>',
'email_msg_email_status_1' => "You have updated your email address for your account \"%s\" on {$_CONF['site_name']}, <{$_CONF['site_url']}>.\n\nPlease click on the following link to verify this email address:\n\n",
'email_msg_email_status_2' => "If you do not verify this email address and you log into your account you will be required to enter a new email address and go through this email verification process again.\n\n"
);

###############################################################################
Expand Down Expand Up @@ -1471,10 +1478,10 @@
20 => '',
21 => 'ユーザー情報を保存しました。',
22 => 'ユーザー情報を削除しました。',
23 => '',
24 => '',
25 => '',
26 => '',
23 => 'Your passwords must match, please try again.',
24 => 'Your emails must match, please try again.',
25 => 'You have not entered a valid email address, please try again.',
26 => 'That email address is already being used by an account, please try again.',
27 => 'メッセージを送信しました。',
28 => 'プラグインを保存しました',
29 => 'あなたはこの管理ページにアクセスできません。権限のない機能へのアクセスはすべて記録しています。',
Expand Down Expand Up @@ -1578,7 +1585,10 @@
153 => 'あなたは %1$d 秒前に友だちに記事を送信しています。次に送信する前に %2$d 秒以上あけてください。',
400 => '検証に通っていない必須のフィールドがあります。',
401 => '氏名を入力してください。',
500 => 'データ、テンプレート、リソース、ファイルマネージャーのキャッシュファイルを削除しました。'
500 => 'データ、テンプレート、リソース、ファイルマネージャーのキャッシュファイルを削除しました。',
501 => 'A verification message has been sent to your email address. Please click on the link in the email to confirm your email address and update your account. If you log into your account again before you verify your email address you will be asked again for a email address.<br' . XHTML . '><br' . XHTML . '>Please note you have now been successfully logged out so you can complete this verification.',
502 => 'Your request for a new email has expired. Please try again below.',
503 => 'Your email has been successfully verified. Please login now.'
);

###############################################################################
Expand Down Expand Up @@ -2118,6 +2128,7 @@
'hide_author_exclusion' => '所有者の非表示を許可する',
'show_fullname' => 'ユーザー名の代わりに氏名を表示する',
'show_servicename' => 'サービス名を表示する',
'require_user_email' => "Require User Email",
'custom_registration' => 'カスタム登録を有効にする',
'user_login_method' => 'ログイン方法',
'facebook_login' => 'FacebookのOAuthを有効にする',
Expand Down
1 change: 1 addition & 0 deletions public_html/admin/configuration_validation.php
Expand Up @@ -308,6 +308,7 @@
$_CONF_VALIDATE['Core']['hide_author_exclusion'] = array('rule' => 'boolean');
$_CONF_VALIDATE['Core']['show_fullname'] = array('rule' => 'boolean');
$_CONF_VALIDATE['Core']['show_servicename'] = array('rule' => 'boolean');
$_CONF_VALIDATE['Core']['require_user_email'] = array('rule' => 'boolean');
$_CONF_VALIDATE['Core']['custom_registration'] = array('rule' => 'boolean');
$_CONF_VALIDATE['Core']['user_login_method[standard]'] = array('rule' => 'boolean');
$_CONF_VALIDATE['Core']['user_login_method[openid]'] = array('rule' => 'boolean');
Expand Down
1 change: 1 addition & 0 deletions public_html/admin/install/config-install.php
Expand Up @@ -227,6 +227,7 @@ function install_config()
$c->add('allow_account_delete',0,'select',4,16,0,270,TRUE, $me, 16);
$c->add('hide_author_exclusion',0,'select',4,16,0,280,TRUE, $me, 16);
$c->add('show_fullname',0,'select',4,16,0,290,TRUE, $me, 16);
$c->add('require_user_email',1,'select',4,16,0,295,TRUE, $me, 16);
$c->add('show_servicename',TRUE,'select',4,16,1,300,TRUE, $me, 16);
$c->add('custom_registration',FALSE,'select',4,16,1,310,TRUE, $me, 16);
$c->add('user_login_method',array('standard' => true, 'openid' => false, '3rdparty' => false, 'oauth' => false),'@select',4,16,1,320,TRUE, $me, 16);
Expand Down
3 changes: 3 additions & 0 deletions public_html/admin/install/devel-db-update.php
Expand Up @@ -107,6 +107,9 @@ function update_DatabaseFor220()
PRIMARY KEY (code)
) ENGINE=MyISAM
";

// Add column to confirm new email address
$_SQL[] = "ALTER TABLE `{$_TABLES['users']}` ADD `emailconfirmid` VARCHAR(16) NULL DEFAULT NULL AFTER `pwrequestid`";

// Add theme admin
$result = DB_query("SELECT * FROM {$_TABLES['groups']} WHERE grp_name='Theme Admin'");
Expand Down
7 changes: 7 additions & 0 deletions public_html/docs/english/config.html
Expand Up @@ -807,6 +807,13 @@ <h3><a name="users_users">Users and Submissions: Users</a></h3>
<td valign="top">Whether to display a user's full name (= 1) or only their
username (= 0). For users that haven't entered their full name, Geeklog
will always display the username.</td></tr>
<tr>
<td valign="top"><a name="desc_require_user_email">require_user_email</a></td>
<td valign="top">true</td>
<td valign="top">If set to true, users will be required to add an email address to their account and need to verify it
before they can continue to use the website while logged in. This affects remote accounts as some
may not return an email address to Geeklog when the account is created due to permissions from the
remote service.</td></tr>
<tr>
<td valign="top"><a name="desc_show_servicename">show_servicename</a></td>
<td valign="top">true</td>
Expand Down
7 changes: 7 additions & 0 deletions public_html/docs/japanese/config.html
Expand Up @@ -744,6 +744,13 @@ <h3><a name="users_users">ユーザーと投稿: ユーザー</a></h3>
<td valign="top"><a name="desc_show_fullname">ユーザー名の代わりに氏名を表示する(show_fullname)</a></td>
<td valign="top">いいえ</td>
<td valign="top">「はい」にするとユーザーのフルネームを表示し、「いいえ」にするとユーザー名しか表示しません。フルネームを入力していない場合は常にユーザー名が表示されます。</td></tr>
<tr>
<td valign="top"><a name="desc_require_user_email">require_user_email</a></td>
<td valign="top">true</td>
<td valign="top">If set to true, users will be required to add an email address to their account and need to verify it
before they can continue to use the website while logged in. This affects remote accounts as some
may not return an email address to Geeklog when the account is created due to permissions from the
remote service.</td></tr>
<tr>
<td valign="top"><a name="desc_show_servicename">サービス名を表示する(show_servicename)</a></td>
<td valign="top">はい</td>
Expand Down
33 changes: 33 additions & 0 deletions public_html/layout/denim/users/newemail.thtml
@@ -0,0 +1,33 @@
{# begin {templatelocation} #}

<form action="{site_url}/users.php" method="post" id="newemail" class="compact">
<fieldset>
<legend>{lang_setnewemail}</legend>

<p class="message">{lang_explain}</p>

<dl>
<dt>{lang_username}</dt>
<dd>{user_name}</dd>

<dt><label for="newemail-email">{lang_newemail}</label></dt>
<dd><input type="text" size="32" maxlength="96" name="email" value="{email}" id="newemail-email" class="text"{xhtml}></dd>

<dt><label for="newemail-email_conf">{lang_newemail_conf}</label></dt>
<dd><input type="text" size="32" maxlength="96" name="email_conf" value="{email_conf}" id="newemail-email_conf" class="text"{xhtml}></dd>
</dl>

{captcha}

<ul class="submit">
<li>
<input type="hidden" name="mode" value="{mode}"{xhtml}>
<input type="hidden" name="uid" value="{user_id}"{xhtml}>
<input type="hidden" name="rid" value="{request_id}"{xhtml}>
<input type="submit" value="{lang_setnewemail}" class="submit"{xhtml}>
</li>
</ul>
</fieldset>
</form>

{# end {templatelocation} #}
33 changes: 33 additions & 0 deletions public_html/layout/modern_curve/users/newemail.thtml
@@ -0,0 +1,33 @@
{# begin {templatelocation} #}

<form action="{site_url}/users.php" method="post" id="newemail" class="compact">
<fieldset>
<legend>{lang_setnewemail}</legend>

<p class="message">{lang_explain}</p>

<dl>
<dt>{lang_username}</dt>
<dd>{user_name}</dd>

<dt><label for="newemail-email">{lang_newemail}</label></dt>
<dd><input type="text" size="32" maxlength="96" name="email" value="{email}" id="newemail-email" class="text"{xhtml}></dd>

<dt><label for="newemail-email_conf">{lang_newemail_conf}</label></dt>
<dd><input type="text" size="32" maxlength="96" name="email_conf" value="{email_conf}" id="newemail-email_conf" class="text"{xhtml}></dd>
</dl>

{captcha}

<ul class="submit">
<li>
<input type="hidden" name="mode" value="{mode}"{xhtml}>
<input type="hidden" name="uid" value="{user_id}"{xhtml}>
<input type="hidden" name="rid" value="{request_id}"{xhtml}>
<input type="submit" value="{lang_setnewemail}" class="submit"{xhtml}>
</li>
</ul>
</fieldset>
</form>

{# end {templatelocation} #}
9 changes: 7 additions & 2 deletions public_html/lib-common.php
Expand Up @@ -3468,11 +3468,16 @@ function COM_mail($to, $subject, $message, $from = '', $html = false, $priority

// Need to check email address to ensure they are not from account that have a status of locked or new email. If so we need to remove them so no email sent
// Email addresses without accounts are not affected
$email = key($to);
if (is_array($to)) {
$email = key($to);
} else {
$email = $to;
}

// If no status exists then assume no user account and email is being sent to someone else (which is fine and should be sent like to new users)
$status = DB_getItem($_TABLES['users'], 'status', "email = '$email'");

if ($status == USER_ACCOUNT_DISABLED || $status == USER_ACCOUNT_LOCKED || $status == USER_ACCOUNT_NEW_EMAIL) {
if (!empty($status) && ($status == USER_ACCOUNT_DISABLED || $status == USER_ACCOUNT_LOCKED || $status == USER_ACCOUNT_NEW_EMAIL)) {
return false;
} else {
return Geeklog\Mail::send($to, $subject, $message, $from, $html, $priority, $optional, $attachments);
Expand Down

0 comments on commit 2f772df

Please sign in to comment.