diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index b0bc4b9c5..8e39edab4 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -14,6 +14,7 @@ - fixed #11912: Corrupt cookie causes server 500 errors - fixed #11919: Survey rendering with section text - fixed #11916: Collaboration System security + - fixed #11918: Make password recovery email templatable 7.10.2 - fixed #11884: Editing Templates impossible / Code editor not loaded diff --git a/docs/upgrades/packages-7.10.3/root_import_auth.wgpkg b/docs/upgrades/packages-7.10.3/root_import_auth.wgpkg new file mode 100644 index 000000000..21f95ac78 Binary files /dev/null and b/docs/upgrades/packages-7.10.3/root_import_auth.wgpkg differ diff --git a/docs/upgrades/upgrade_7.10.2-7.10.3.pl b/docs/upgrades/upgrade_7.10.2-7.10.3.pl index e34b26b8a..3acbc26fe 100644 --- a/docs/upgrades/upgrade_7.10.2-7.10.3.pl +++ b/docs/upgrades/upgrade_7.10.2-7.10.3.pl @@ -33,6 +33,7 @@ my $session = start(); # this line required # upgrade functions go here pruneInboxMessagesFromDeletedUsers($session); addTemplateToNotifyAboutVersionTag($session); +addPasswordRecoveryEmailTemplate($session); finish($session); # this line required @@ -83,6 +84,16 @@ sub addTemplateToNotifyAboutVersionTag { } +#---------------------------------------------------------------------------- +# Describe what our function does +sub addPasswordRecoveryEmailTemplate { + my $session = shift; + print "\tAdd a template for the password recovery email." unless $quiet; + $session->setting->add('webguiPasswordRecoveryEmailTemplate', 'sK_0zVw4kwdJ1sqREIsSzA'); + print "...DONE!\n" unless $quiet; +} + + # -------------- DO NOT EDIT BELOW THIS LINE -------------------------------- #---------------------------------------------------------------------------- diff --git a/lib/WebGUI/Auth/WebGUI.pm b/lib/WebGUI/Auth/WebGUI.pm index f96fc4c6b..ca5f46e28 100644 --- a/lib/WebGUI/Auth/WebGUI.pm +++ b/lib/WebGUI/Auth/WebGUI.pm @@ -22,6 +22,7 @@ use WebGUI::Storage; use WebGUI::User; use WebGUI::Utility; use WebGUI::Form::Captcha; +use WebGUI::Macro; use Encode (); our @ISA = qw(WebGUI::Auth); @@ -609,6 +610,13 @@ sub editUserSettingsForm { -label => $i18n->get("password recovery template"), -hoverHelp => $i18n->get("password recovery template help") ); + $f->template( + -name => "webguiPasswordRecoveryEmailTemplate", + -value => $self->session->setting->get('webguiPasswordRecoveryEmailTemplate'), + -label => $i18n->get('Password Recovery Email Template'), + -hoverHelp => $i18n->get("password recovery email template help"), + -namespace => "Auth/WebGUI/RecoveryEmail", + ); $f->template( -name => "webguiWelcomeMessageTemplate", -value => $self->session->setting->get("webguiWelcomeMessageTemplate"), @@ -678,6 +686,8 @@ sub editUserSettingsFormSave { $s->set("webguiPasswordRecoveryTemplate", $f->process("webguiPasswordRecoveryTemplate","template")); $s->set("webguiWelcomeMessageTemplate", $f->process("webguiWelcomeMessageTemplate","template")); $s->set("webguiAccountActivationTemplate", $f->process("webguiAccountActivationTemplate","template")); + $s->set("webguiPasswordRecoveryTemplate", $f->process("webguiPasswordRecoveryTemplate","template")); + $s->set("webguiPasswordRecoveryEmailTemplate", $f->process("webguiPasswordRecoveryEmailTemplate","template")); if (@errors) { return \@errors; @@ -1102,7 +1112,6 @@ sub emailRecoverPasswordFinish { # generate information necessry to proceed my $recoveryGuid = $session->id->generate(); - my $url = $session->url->getSiteURL; my $userId = $user->userId; #get the user guid $email = $user->profileField('email'); @@ -1116,7 +1125,12 @@ sub emailRecoverPasswordFinish { $self->saveParams($userId, 'WebGUI', $authsettings); my $mail = WebGUI::Mail::Send->create($session, { to=>$email, subject=>$i18n->get('WebGUI password recovery')}); - $mail->addText($i18n->get('recover password email text1', 'AuthWebGUI') . $url. ". \n\n".$i18n->get('recover password email text2', 'AuthWebGUI')." \n\n ".$url."?op=auth;method=emailResetPassword;token=$recoveryGuid"."\n\n ". $i18n->get('recover password email text3', 'AuthWebGUI')); + my $vars = { }; + $vars->{recoverPasswordUrl} = $session->url->append($session->url->getSiteURL,'?op=auth;method=emailResetPassword;token='.$recoveryGuid); + my $template = WebGUI::Asset->newByDynamicClass($session, $session->setting->get('webguiPasswordRecoveryEmailTemplate')); + my $emailText = $template->process($vars); + WebGUI::Macro::process($session, \$emailText); + $mail->addText($emailText); $mail->queue; return "

". $i18n->get('recover password banner', 'AuthWebGUI')."



". $i18n->get('email recover password finish message', 'AuthWebGUI') . "

"; } diff --git a/lib/WebGUI/Help/AuthWebGUI.pm b/lib/WebGUI/Help/AuthWebGUI.pm index 04cec68f7..124a92c7b 100644 --- a/lib/WebGUI/Help/AuthWebGUI.pm +++ b/lib/WebGUI/Help/AuthWebGUI.pm @@ -129,6 +129,16 @@ our $HELP = { related => [] }, + 'webgui authentication password recovery email template' => { + title => 'recovery email template title', + body => '', + variables => [ + { 'name' => 'recoverPasswordUrl', }, + ], + fields => [], + related => [] + }, + 'webgui authentication password expiration template' => { title => 'expired template title', body => '', diff --git a/lib/WebGUI/i18n/English/AuthWebGUI.pm b/lib/WebGUI/i18n/English/AuthWebGUI.pm index a3f2f3bec..c697102da 100644 --- a/lib/WebGUI/i18n/English/AuthWebGUI.pm +++ b/lib/WebGUI/i18n/English/AuthWebGUI.pm @@ -735,8 +735,9 @@ Settings screen, displayed as hoverhelp.|, }, 'recover password email text1' => { - message => q|We have received your request to change the password for |, + message => q|We have received your request to change the password for %s.|, lastUpdated => 1189780432, + context => q|%s is the URL of the site|, }, 'recover password email text2' => { @@ -823,6 +824,31 @@ Settings screen, displayed as hoverhelp.|, lastUpdated => 0, context => q|Description of the webguiUseEmailAsUsername field, used as hoverhelp on the Auth tab of the Edit Settings screen.|, }, + + 'Password Recovery Email Template' => { + message => 'Password Recovery Email Template', + lastUpdated => 0, + context => q|Label in the auth settings|, + }, + + 'password recovery email template help' => { + message => 'Choose a template to style the emails sent out for recovering passwords', + lastUpdated => 0, + context => q|Label in the auth settings|, + }, + + 'recovery email template title' => { + message => 'WebGUI Authentication Password Recovery Email Template', + lastUpdated => 0, + context => q|template help|, + }, + + 'recoverPasswordUrl' => { + message => 'The URL for the user to visit to reset their password.', + lastUpdated => 0, + context => q|template help|, + }, + }; 1;