Skip to content

Commit

Permalink
Send email when user is locked (#2176)
Browse files Browse the repository at this point in the history
* based on feedback from #2137 (#2168)

* send email when the user is locked

* Apply fixes from StyleCI (#2175)

* fix 1049
  • Loading branch information
DawoudIO authored Mar 25, 2017
1 parent e7f7bc6 commit 4318e3c
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 25 deletions.
12 changes: 3 additions & 9 deletions src/ChurchCRM/Emails/users/AccountDeletedEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,16 @@
class AccountDeletedEmail extends BaseUserEmail
{

protected $password;

public function __construct($user, $password) {
$this->password = $password;
parent::__construct($user);
}

protected function getSubSubject()
{
return gettext("Your CRM Account was Deleted");
return gettext("Your ChurchCRM Account was Deleted");
}

protected function buildMessageBody()
{
$msg = array();
array_push($msg, gettext("Your CRM Account was Deleted, if you think this is an error, please contact your admin"));
array_push($msg, gettext("Your ChurchCRM Account was Deleted."));
array_push($msg, gettext("If you think this is an error") . " " . gettext("please contact your admin"));
return implode("<p/>", $msg);
}
}
2 changes: 1 addition & 1 deletion src/ChurchCRM/Emails/users/BaseUserEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ protected function buildMessage(){

protected function buildMessageHeader()
{
return gettext("Dear") ." " . $this->user->getFullName();
return SystemConfig::getValue('sDear') ." " . $this->user->getFullName();
}

protected abstract function buildMessageBody();
Expand Down
21 changes: 21 additions & 0 deletions src/ChurchCRM/Emails/users/LockedEmail.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace ChurchCRM\Emails;


class LockedEmail extends BaseUserEmail
{

protected function getSubSubject()
{
return gettext("Account Locked");
}

protected function buildMessageBody()
{
$msg = array();
array_push($msg, gettext("We wanted to let you know that your ChurchCRM account was locked."));
array_push($msg, gettext("If you think this is an error") . " " . gettext("please contact your admin"));
return implode("<p/>", $msg);
}
}
4 changes: 2 additions & 2 deletions src/ChurchCRM/Emails/users/NewAccountEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function __construct($user, $password) {

protected function getSubSubject()
{
return gettext("Your CRM Account");
return gettext("Your ChurchCRM Account");
}

protected function buildMessageBody()
Expand All @@ -24,7 +24,7 @@ protected function buildMessageBody()
array_push($msg, gettext("A ChurchCRM account was created for you:"));
array_push($msg, "<a href='" . $this->getLink() . "'>" . gettext("Login"). "</a>");
array_push($msg, gettext('Username') . ": " . $this->user->getUserName());
array_push($msg, gettext('New Password') . ": " . $this->password);
array_push($msg, gettext('Password') . ": " . $this->password);
return implode("<p/>", $msg);
}
}
6 changes: 1 addition & 5 deletions src/ChurchCRM/Emails/users/PasswordChangeEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
class PasswordChangeEmail extends BaseUserEmail
{

public function __construct($user) {
parent::__construct($user);
}

protected function getSubSubject()
{
return gettext("Password Changed");
Expand All @@ -18,7 +14,7 @@ protected function getSubSubject()
protected function buildMessageBody()
{
$msg = array();
array_push($msg, gettext("We wanted to let you know that your password was changed."));
array_push($msg, gettext("We wanted to let you know that your ChurchCRM password was changed."));
return implode("<p/>", $msg);
}
}
2 changes: 1 addition & 1 deletion src/ChurchCRM/Emails/users/ResetPasswordEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function __construct($user, $password) {

protected function getSubSubject()
{
return gettext("Your CRM New Password");
return gettext("Your ChurchCRM New Password");
}

protected function buildMessageBody()
Expand Down
6 changes: 1 addition & 5 deletions src/ChurchCRM/Emails/users/UnlockedEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
class UnlockedEmail extends BaseUserEmail
{

public function __construct($user) {
parent::__construct($user);
}

protected function getSubSubject()
{
return gettext("Account Unlocked");
Expand All @@ -18,7 +14,7 @@ protected function getSubSubject()
protected function buildMessageBody()
{
$msg = array();
array_push($msg, gettext("We wanted to let you know that your account was unlocked."));
array_push($msg, gettext("We wanted to let you know that your ChurchCRM account was unlocked."));
array_push($msg, "<a href='" . $this->getLink() . "'>" . gettext("Login"). "</a>");
array_push($msg, gettext('Username') . ": " . $this->user->getUserName());
return implode("<p/>", $msg);
Expand Down
3 changes: 2 additions & 1 deletion src/ChurchCRM/dto/SystemConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ private static function buildConfigs()
"sLastIntegrityCheckTimeStamp" => new ConfigItem(1046, "sLastIntegrityCheckTimeStamp", "text", "", gettext("Last Integrity Check Timestamp")),
"sChurchCountry" => new ConfigItem(1047, "sChurchCountry", "choice", "", "", json_encode(["Choices" => Countries::getNames()])),
"sConfirmSincerely" => new ConfigItem(1048, "sConfirmSincerely", "text", "Sincerely", gettext("Used to end a letter before Signer")),
"sDear" => new ConfigItem(1049, "sDear", "text", "Dear", gettext("Text before name in emails/reports")),
"googleTrackingID" => new ConfigItem(1050, "googleTrackingID", "text", "", gettext("Google Analytics Tracking Code")),
"mailChimpApiKey" => new ConfigItem(2000, "mailChimpApiKey", "text", "", gettext("see http://kb.mailchimp.com/accounts/management/about-api-keys")),
"sDepositSlipType" => new ConfigItem(2001, "sDepositSlipType", "choice", "QBDT", gettext("Deposit ticket type. QBDT - Quickbooks"), '{"Choices":["QBDT"]}'),
Expand All @@ -176,7 +177,7 @@ private static function buildCategories()
gettext('Member Setup') => ["sDirClassifications","sDirRoleHead","sDirRoleSpouse","sDirRoleChild","sDefaultCity","sDefaultState","sDefaultCountry","bShowFamilyData","bHidePersonAddress","bHideFriendDate","bHideFamilyNewsletter","bHideWeddingDate","bHideLatLon","cfgForceUppercaseZip","sEnableGravatarPhotos","sEnableSelfRegistration", "bAllowEmptyLastName", "iPersonNameStyle"],
gettext('System Settings') => ["sLastBackupTimeStamp","sExternalBackupAutoInterval","sExternalBackupPassword","sEnableExternalBackupTarget","sExternalBackupType","sExternalBackupEndpoint","sExternalBackupUsername","debug","bRegistered","sXML_RPC_PATH","sGZIPname","sZIPname","sPGPname","bCSVAdminOnly","sHeader","sEnableIntegrityCheck","sIntegrityCheckInterval","sLastIntegrityCheckTimeStamp"],
gettext('Map Settings') => ["sGoogleMapKey","bUseGoogleGeocode","sGMapIcons","sISTusername","sISTpassword","sGeocoderID","sGeocoderPW"],
gettext('Report Settings') => ["sQBDTSettings","leftX","incrementY","sTaxReport1","sTaxReport2","sTaxReport3","sTaxSigner","sReminder1","sReminderSigner","sReminderNoPledge","sReminderNoPayments","sConfirm1","sConfirm2","sConfirm3","sConfirm4","sConfirm5","sConfirm6","sConfirmSincerely","sConfirmSigner","sPledgeSummary1","sPledgeSummary2","sDirectoryDisclaimer1","sDirectoryDisclaimer2","bDirLetterHead","sZeroGivers","sZeroGivers2","sZeroGivers3"],
gettext('Report Settings') => ["sQBDTSettings","leftX","incrementY","sTaxReport1","sTaxReport2","sTaxReport3","sTaxSigner","sReminder1","sReminderSigner","sReminderNoPledge","sReminderNoPayments","sConfirm1","sConfirm2","sConfirm3","sConfirm4","sConfirm5","sConfirm6","sDear","sConfirmSincerely","sConfirmSigner","sPledgeSummary1","sPledgeSummary2","sDirectoryDisclaimer1","sDirectoryDisclaimer2","bDirLetterHead","sZeroGivers","sZeroGivers2","sZeroGivers3"],
gettext('Localization') => ["sLanguage","sDistanceUnit","sPhoneFormat","sPhoneFormatWithExt","sDateFormatLong","sDateFormatNoYear","sDateFormatShort","sDateTimeFormat","sDateFilenameFormat"],
gettext('Financial Settings') => ["sDepositSlipType","iChecksPerDepositForm","bDisplayBillCounts","bUseScannedChecks","sElectronicTransactionProcessor","bEnableNonDeductible","iFYMonth","bUseDonationEnvelopes","aFinanceQueries"],
gettext('Other Settings') => ["iPDFOutputType","googleTrackingID"]
Expand Down
8 changes: 7 additions & 1 deletion src/Login.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
use ChurchCRM\dto\SystemConfig;
use ChurchCRM\Service\SystemService;
use ChurchCRM\UserQuery;
use ChurchCRM\Emails\LockedEmail;

$systemService = new SystemService();

Expand Down Expand Up @@ -131,6 +132,10 @@
// Increment the FailedLogins
$currentUser->setFailedLogins($currentUser->getFailedLogins() + 1);
$currentUser->save();
if (!empty($currentUser->getEmail()) && $currentUser->isLocked()) {
$lockedEmail = new LockedEmail($currentUser);
$lockedEmail->send();
}

// Set the error text
$sErrorText = gettext('Invalid login or password');
Expand Down Expand Up @@ -278,7 +283,8 @@
<?php if ($enableSelfReg) {
?>
<a href="external/register/" class="text-center btn bg-olive"><i class="fa fa-user-plus"></i> <?= gettext('Register a new Family'); ?></a><br>
<?php
<?php

} ?>
<!--<a href="external/family/verify" class="text-center">Verify Family Info</a> -->
</div>
Expand Down

0 comments on commit 4318e3c

Please sign in to comment.