Browse Source

unlock account emil notices

Jason Rivard 8 years ago
parent
commit
ac02e61249

+ 4 - 0
src/main/java/password/pwm/config/PwmSetting.java

@@ -317,6 +317,10 @@ public enum PwmSetting {
             "email.intruderNotice", PwmSettingSyntax.EMAIL, PwmSettingCategory.EMAIL_TEMPLATES),
             "email.intruderNotice", PwmSettingSyntax.EMAIL, PwmSettingCategory.EMAIL_TEMPLATES),
     EMAIL_DELETEACCOUNT(
     EMAIL_DELETEACCOUNT(
             "email.deleteAccount", PwmSettingSyntax.EMAIL, PwmSettingCategory.EMAIL_TEMPLATES),
             "email.deleteAccount", PwmSettingSyntax.EMAIL, PwmSettingCategory.EMAIL_TEMPLATES),
+    EMAIL_HELPDESK_UNLOCK(
+            "email.helpdesk.unlock", PwmSettingSyntax.EMAIL, PwmSettingCategory.EMAIL_TEMPLATES),
+    EMAIL_UNLOCK(
+            "email.unlock", PwmSettingSyntax.EMAIL, PwmSettingCategory.EMAIL_TEMPLATES),
 
 
     EMAIL_ADVANCED_SETTINGS(
     EMAIL_ADVANCED_SETTINGS(
             "email.smtp.advancedSettings", PwmSettingSyntax.STRING_ARRAY, PwmSettingCategory.EMAIL_SETTINGS),
             "email.smtp.advancedSettings", PwmSettingSyntax.STRING_ARRAY, PwmSettingCategory.EMAIL_SETTINGS),

+ 35 - 0
src/main/java/password/pwm/http/servlet/forgottenpw/ForgottenPasswordServlet.java

@@ -922,6 +922,8 @@ public class ForgottenPasswordServlet extends AbstractPwmServlet {
             final UserInfoBean userInfoBean = readUserInfoBean(pwmRequest, forgottenPasswordBean);
             final UserInfoBean userInfoBean = readUserInfoBean(pwmRequest, forgottenPasswordBean);
             pwmApplication.getAuditManager().submit(AuditEvent.UNLOCK_PASSWORD, userInfoBean, pwmSession);
             pwmApplication.getAuditManager().submit(AuditEvent.UNLOCK_PASSWORD, userInfoBean, pwmSession);
 
 
+            sendUnlockNoticeEmail(pwmRequest, forgottenPasswordBean);
+
             pwmRequest.getPwmResponse().forwardToSuccessPage(Message.Success_UnlockAccount);
             pwmRequest.getPwmResponse().forwardToSuccessPage(Message.Success_UnlockAccount);
         } catch (ChaiOperationException e) {
         } catch (ChaiOperationException e) {
             final String errorMsg = "unable to unlock user " + userIdentity + " error: " + e.getMessage();
             final String errorMsg = "unable to unlock user " + userIdentity + " error: " + e.getMessage();
@@ -1786,6 +1788,39 @@ public class ForgottenPasswordServlet extends AbstractPwmServlet {
 
 
         return responseSet;
         return responseSet;
     }
     }
+
+    private static void sendUnlockNoticeEmail(
+            final PwmRequest pwmRequest,
+            final ForgottenPasswordBean forgottenPasswordBean
+    )
+            throws PwmUnrecoverableException, ChaiUnavailableException, IOException, ServletException
+    {
+        final PwmApplication pwmApplication = pwmRequest.getPwmApplication();
+        final Configuration config = pwmRequest.getConfig();
+        final Locale locale = pwmRequest.getLocale();
+        final UserIdentity userIdentity = forgottenPasswordBean.getUserIdentity();
+        final EmailItemBean configuredEmailSetting = config.readSettingAsEmail(PwmSetting.EMAIL_UNLOCK, locale);
+
+        if (configuredEmailSetting == null) {
+            LOGGER.debug(pwmRequest, "skipping send unlock notice email for '" + userIdentity + "' no email configured");
+            return;
+        }
+
+        final UserInfoBean userInfoBean = readUserInfoBean(pwmRequest, forgottenPasswordBean);
+        final MacroMachine macroMachine = new MacroMachine(
+                pwmApplication,
+                pwmRequest.getSessionLabel(),
+                userInfoBean,
+                null,
+                LdapUserDataReader.appProxiedReader(pwmApplication, userIdentity)
+        );
+
+        pwmApplication.getEmailQueue().submitEmail(
+                configuredEmailSetting,
+                userInfoBean,
+                macroMachine
+        );
+    }
 }
 }
 
 
 
 

+ 36 - 0
src/main/java/password/pwm/http/servlet/helpdesk/HelpdeskServlet.java

@@ -687,6 +687,9 @@ public class HelpdeskServlet extends AbstractPwmServlet {
             intruderManager.convenience().clearUserIdentity(userIdentity);
             intruderManager.convenience().clearUserIdentity(userIdentity);
         }
         }
 
 
+        // send notice email
+        sendUnlockNoticeEmail(pwmRequest, helpdeskProfile, userIdentity);
+
         final boolean useProxy = helpdeskProfile.readSettingAsBoolean(PwmSetting.HELPDESK_USE_PROXY);
         final boolean useProxy = helpdeskProfile.readSettingAsBoolean(PwmSetting.HELPDESK_USE_PROXY);
         try {
         try {
             final ChaiUser chaiUser = useProxy ?
             final ChaiUser chaiUser = useProxy ?
@@ -1232,4 +1235,37 @@ public class HelpdeskServlet extends AbstractPwmServlet {
         final RestResultBean restResultBean = new RestResultBean(responseBean);
         final RestResultBean restResultBean = new RestResultBean(responseBean);
         pwmRequest.outputJsonResult(restResultBean);
         pwmRequest.outputJsonResult(restResultBean);
     }
     }
+
+    private static void sendUnlockNoticeEmail(
+            final PwmRequest pwmRequest,
+            final HelpdeskProfile helpdeskProfile,
+            final UserIdentity userIdentity
+    )
+            throws PwmUnrecoverableException, ChaiUnavailableException, IOException, ServletException {
+        final PwmApplication pwmApplication = pwmRequest.getPwmApplication();
+        final Configuration config = pwmRequest.getConfig();
+        final Locale locale = pwmRequest.getLocale();
+        final EmailItemBean configuredEmailSetting = config.readSettingAsEmail(PwmSetting.EMAIL_HELPDESK_UNLOCK, locale);
+
+        if (configuredEmailSetting == null) {
+            LOGGER.debug(pwmRequest, "skipping send helpdesk unlock notice email for '" + userIdentity + "' no email configured");
+            return;
+        }
+
+        final HelpdeskDetailInfoBean helpdeskDetailInfoBean = makeHelpdeskDetailInfo(pwmRequest, helpdeskProfile, userIdentity);
+        final MacroMachine macroMachine = new MacroMachine(
+                pwmApplication,
+                pwmRequest.getSessionLabel(),
+                helpdeskDetailInfoBean.getUserInfoBean(),
+                null,
+                LdapUserDataReader.appProxiedReader(pwmApplication, userIdentity)
+        );
+
+        pwmApplication.getEmailQueue().submitEmail(
+                configuredEmailSetting,
+                helpdeskDetailInfoBean.getUserInfoBean(),
+                macroMachine
+        );
+    }
+
 }
 }

+ 12 - 0
src/main/resources/password/pwm/config/PwmSetting.xml

@@ -799,6 +799,18 @@
             <value>{"to":"@User:Email@","from":"Delete Account Notice \u003c@DefaultEmailFromAddress@\u003e","subject":"Account Deletion Notice","bodyPlain":"Your account has been deleted at your request.","bodyHtml":""}</value>
             <value>{"to":"@User:Email@","from":"Delete Account Notice \u003c@DefaultEmailFromAddress@\u003e","subject":"Account Deletion Notice","bodyPlain":"Your account has been deleted at your request.","bodyHtml":""}</value>
         </default>
         </default>
     </setting>
     </setting>
+    <setting hidden="false" key="email.helpdesk.unlock" level="1">
+        <flag>MacroSupport</flag>
+        <default>
+            <value>{"to":"@User:Email@","from":"Unlock Account Notice \u003c@DefaultEmailFromAddress@\u003e","subject":"Account Unlock Notice","bodyPlain":"Your account has been unlocked by the helpdesk.","bodyHtml":""}</value>
+        </default>
+    </setting>
+    <setting hidden="false" key="email.unlock" level="1">
+        <flag>MacroSupport</flag>
+        <default>
+            <value>{"to":"@User:Email@","from":"Unlock Account Notice \u003c@DefaultEmailFromAddress@\u003e","subject":"Account Unlock Notice","bodyPlain":"Your account has been unlocked.","bodyHtml":""}</value>
+        </default>
+    </setting>
     <setting hidden="false" key="email.smtp.advancedSettings" level="2">
     <setting hidden="false" key="email.smtp.advancedSettings" level="2">
         <regex>^[a-zA-Z0-9.]+=.+$</regex>
         <regex>^[a-zA-Z0-9.]+=.+$</regex>
         <default/>
         <default/>

+ 4 - 0
src/main/resources/password/pwm/i18n/PwmSetting.properties

@@ -308,6 +308,7 @@ Setting_Description_email.default.fromAddress=Specify a default From Address for
 Setting_Description_email.deleteAccount=Define this template to send an email to the users after the Account Delete action.
 Setting_Description_email.deleteAccount=Define this template to send an email to the users after the Account Delete action.
 Setting_Description_email.guest=Define this template to send an email to newly created guest users.
 Setting_Description_email.guest=Define this template to send an email to newly created guest users.
 Setting_Description_email.helpdesk.token=Define this template to send an email during the Help Desk verification process.  You can use %TOKEN% to insert the token value into the email.
 Setting_Description_email.helpdesk.token=Define this template to send an email during the Help Desk verification process.  You can use %TOKEN% to insert the token value into the email.
+Setting_Description_email.helpdesk.unlock=Define this template to send an email to users to whose account is unlocked by the help desk.
 Setting_Description_email.intruderNotice=Deinfe this template to send an email when a userDN intruder lockout occurs.
 Setting_Description_email.intruderNotice=Deinfe this template to send an email when a userDN intruder lockout occurs.
 Setting_Description_email.newUser=Define this template to send an email to newly created users.
 Setting_Description_email.newUser=Define this template to send an email to newly created users.
 Setting_Description_email.newUser.token=Define this template to send an email during the new user verification process.  You can use %TOKEN% to insert the token value into the email.
 Setting_Description_email.newUser.token=Define this template to send an email during the new user verification process.  You can use %TOKEN% to insert the token value into the email.
@@ -319,6 +320,7 @@ Setting_Description_email.smtp.advancedSettings=Add Name/Value settings to contr
 Setting_Description_email.smtp.port=Specify the network port number for the SMTP server.
 Setting_Description_email.smtp.port=Specify the network port number for the SMTP server.
 Setting_Description_email.smtp.username=Specify an SMTP user that logs in to the SMTP server so that it can send the emails @PwmAppName@ generates.  A blank value here sends SMTP messages without authentication.
 Setting_Description_email.smtp.username=Specify an SMTP user that logs in to the SMTP server so that it can send the emails @PwmAppName@ generates.  A blank value here sends SMTP messages without authentication.
 Setting_Description_email.smtp.userpassword=Specify the password for the SMTP user.  A blank value here sends SMTP messages without authentication.
 Setting_Description_email.smtp.userpassword=Specify the password for the SMTP user.  A blank value here sends SMTP messages without authentication.
+Setting_Description_email.unlock=Define this template to send an email to users who unlock their own account.
 Setting_Description_email.updateguest=Define this template to send an email to updated guest users.
 Setting_Description_email.updateguest=Define this template to send an email to updated guest users.
 Setting_Description_email.updateProfile=Define this template to send an email to users after a profile update.
 Setting_Description_email.updateProfile=Define this template to send an email to users after a profile update.
 Setting_Description_email.updateProfile.token=Define this template to send an email to users during the profile email validation.
 Setting_Description_email.updateProfile.token=Define this template to send an email to users during the profile email validation.
@@ -780,6 +782,7 @@ Setting_Label_email.default.fromAddress=Default From Address
 Setting_Label_email.deleteAccount=Delete Account Email
 Setting_Label_email.deleteAccount=Delete Account Email
 Setting_Label_email.guest=Guest Registration Email
 Setting_Label_email.guest=Guest Registration Email
 Setting_Label_email.helpdesk.token=Help Desk Verification Email
 Setting_Label_email.helpdesk.token=Help Desk Verification Email
+Setting_Label_email.helpdesk.unlock=Help Desk Unlock Account Email
 Setting_Label_email.intruderNotice=Intruder Notice Email
 Setting_Label_email.intruderNotice=Intruder Notice Email
 Setting_Label_email.newUser=New User Email
 Setting_Label_email.newUser=New User Email
 Setting_Label_email.newUser.token=New User Verification Email
 Setting_Label_email.newUser.token=New User Verification Email
@@ -791,6 +794,7 @@ Setting_Label_email.smtp.advancedSettings=SMTP Email Advanced Settings
 Setting_Label_email.smtp.port=SMTP Email Server Port
 Setting_Label_email.smtp.port=SMTP Email Server Port
 Setting_Label_email.smtp.username=SMTP Email Server User Name
 Setting_Label_email.smtp.username=SMTP Email Server User Name
 Setting_Label_email.smtp.userpassword=SMTP Email Server Password
 Setting_Label_email.smtp.userpassword=SMTP Email Server Password
+Setting_Label_email.unlock=Unlock Account Email
 Setting_Label_email.updateguest=Guest Registration Update Email
 Setting_Label_email.updateguest=Guest Registration Update Email
 Setting_Label_email.updateProfile.token=Update Profile Email Verification
 Setting_Label_email.updateProfile.token=Update Profile Email Verification
 Setting_Label_email.updateProfile=Update Profile Email
 Setting_Label_email.updateProfile=Update Profile Email

+ 5 - 5
src/main/webapp/WEB-INF/jsp/fragment/header-body.jsp

@@ -58,12 +58,13 @@
                 </div>
                 </div>
 
 
                 <% if (!JspUtility.isFlag(request, PwmRequestFlag.HIDE_HEADER_BUTTONS)) { %>
                 <% if (!JspUtility.isFlag(request, PwmRequestFlag.HIDE_HEADER_BUTTONS)) { %>
-                <pwm:if test="<%=PwmIfTest.forcedPageView%>" negate="true">
                     <pwm:if test="<%=PwmIfTest.authenticated%>">
                     <pwm:if test="<%=PwmIfTest.authenticated%>">
                         <pwm:if test="<%=PwmIfTest.showHome%>">
                         <pwm:if test="<%=PwmIfTest.showHome%>">
-                            <a class="header-button" href="<pwm:value name="<%=PwmValue.homeURL%>"/>" id="HomeButton">
-                                <pwm:if test="<%=PwmIfTest.showIcons%>"><span class="pwm-icon pwm-icon-home" title="<pwm:display key="Button_Home"/>"></span></pwm:if>
-                            </a>
+                            <pwm:if test="<%=PwmIfTest.forcedPageView%>" negate="true">
+                                <a class="header-button" href="<pwm:value name="<%=PwmValue.homeURL%>"/>" id="HomeButton">
+                                    <pwm:if test="<%=PwmIfTest.showIcons%>"><span class="pwm-icon pwm-icon-home" title="<pwm:display key="Button_Home"/>"></span></pwm:if>
+                                </a>
+                            </pwm:if>
                         </pwm:if>
                         </pwm:if>
                         <pwm:if test="<%=PwmIfTest.showLogout%>">
                         <pwm:if test="<%=PwmIfTest.showLogout%>">
                             <a class="header-button" href="<pwm:url url='<%=PwmServletDefinition.Logout.servletUrl()%>' addContext="true"/>" id="LogoutButton">
                             <a class="header-button" href="<pwm:url url='<%=PwmServletDefinition.Logout.servletUrl()%>' addContext="true"/>" id="LogoutButton">
@@ -71,7 +72,6 @@
                             </a>
                             </a>
                         </pwm:if>
                         </pwm:if>
                     </pwm:if>
                     </pwm:if>
-                </pwm:if>
                 <% } %>
                 <% } %>
             </div>
             </div>
         </div>
         </div>