ソースを参照

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	server/src/main/webapp/public/resources/js/changepassword.js
Jason Rivard 7 年 前
コミット
7b45016c02

+ 83 - 0
client/src/pages/changepassword/changepassword.controller.ts

@@ -0,0 +1,83 @@
+/*
+ * Password Management Servlets (PWM)
+ * http://www.pwm-project.org
+ *
+ * Copyright (c) 2006-2009 Novell, Inc.
+ * Copyright (c) 2009-2017 The PWM Project
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+/* tslint:disable */
+
+import {ICompileService, IScope, ITemplateCacheService, element} from 'angular';
+
+declare const PWM_GLOBAL: any;
+declare const PWM_MAIN: any;
+
+const PWM_CHANGEPW = window['PWM_CHANGEPW'];
+const PW_SUGGESTIONS_TEMPLATE = require("pages/changepassword/password-suggestions.html");
+require("pages/changepassword/password-suggestions.scss");
+
+export default class ChangePasswordController {
+    static $inject = ["$scope", "$compile", "$templateCache"];
+    constructor(
+            private $scope: IScope,
+            private $compile: ICompileService,
+            private $templateCache: ITemplateCacheService
+    ) {
+    }
+
+    getString(key: string) {
+        return PWM_MAIN.showString(key);
+    }
+
+    doRandomGeneration() {
+        PWM_MAIN.showDialog({
+            title: PWM_MAIN.showString('Title_RandomPasswords'),
+            dialogClass: 'narrow',
+            text: "",
+            showOk: false,
+            showClose: true,
+            loadFunction: () => {
+                this.populateDialog()
+            }
+        });
+    }
+
+    populateDialog() {
+        this.$scope.$ctrl = this;
+        const passwordSuggestionsElement: JQuery<HTMLElement> = this.$compile(this.$templateCache.get(PW_SUGGESTIONS_TEMPLATE) as string)(this.$scope);
+
+        var myElement = element( document.querySelector( '#dialogPopup .dialogBody, #html5Dialog .dialogBody' ) );
+        myElement.replaceWith(passwordSuggestionsElement);
+
+        this.$scope.$applyAsync();
+
+        PWM_CHANGEPW.beginFetchRandoms({});
+    }
+
+    onChoosePassword(event) {
+        PWM_CHANGEPW.copyToPasswordFields(event.target.textContent);
+    }
+
+    onMoreRandomsButtonClick() {
+        PWM_CHANGEPW.beginFetchRandoms({});
+    }
+
+    onCancelRandomsButtonClick() {
+        PWM_MAIN.closeWaitDialog('dialogPopup');
+    }
+}

+ 29 - 0
client/src/pages/changepassword/changepassword.module.ts

@@ -0,0 +1,29 @@
+/*
+ * Password Management Servlets (PWM)
+ * http://www.pwm-project.org
+ *
+ * Copyright (c) 2006-2009 Novell, Inc.
+ * Copyright (c) 2009-2017 The PWM Project
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+/* tslint:disable */
+
+import { module } from 'angular';
+import ChangePasswordController from './changepassword.controller';
+
+module("changepassword.module", [])
+    .controller("ChangePasswordController", ChangePasswordController);

+ 35 - 0
client/src/pages/changepassword/password-suggestions.html

@@ -0,0 +1,35 @@
+<div class="dialogBody narrow">
+    {{$ctrl.getString('Display_PasswordGeneration')}}
+    <br><br>
+    <table class="noborder">
+        <tbody>
+
+        <tr class="noborder" ng-repeat="i in [0,2,4,6,8,10,12,14,16,18]">
+            <td class="noborder" ng-repeat="j in [i, i+1]" style="padding-bottom: 5px;" width="20%">
+                <div style="visibility: visible;" class="link-randomPasswordValue" href="#" id="randomGen{{j}}"
+                    ng-click="$ctrl.onChoosePassword($event)">
+                </div>
+            </td>
+        </tr>
+        </tbody>
+    </table>
+    <br><br>
+    <table class="noborder">
+        <tbody>
+        <tr class="noborder">
+            <td class="noborder">
+                <button class="btn" id="moreRandomsButton" ng-click="$ctrl.onMoreRandomsButtonClick()">
+                    <span class="btn-icon pwm-icon pwm-icon-refresh"></span>
+                    {{$ctrl.getString('Button_More')}}
+                </button>
+            </td>
+            <td class="noborder" style="text-align:right;">
+                <button class="btn" id="cancelRandomsButton" ng-click="$ctrl.onCancelRandomsButtonClick()">
+                    <span class="btn-icon pwm-icon pwm-icon-times"></span>
+                    {{$ctrl.getString('Button_Cancel')}}
+                </button>
+            </td>
+        </tr>
+        </tbody>
+    </table>
+</div>

+ 3 - 0
client/src/pages/changepassword/password-suggestions.scss

@@ -0,0 +1,3 @@
+#dialogPopup .dialogBody, #html5Dialog .dialogBody {
+    height: 395px;
+}

+ 2 - 1
client/webpack.build.js

@@ -28,7 +28,8 @@ var webpackMerge = require('webpack-merge');
 module.exports = webpackMerge(commonConfig, {
 module.exports = webpackMerge(commonConfig, {
     devtool: 'source-map',
     devtool: 'source-map',
     entry: {
     entry: {
-        'peoplesearch.ng': './src/main'
+        'peoplesearch.ng': './src/main',
+        'changepassword.ng': './src/pages/changepassword/changepassword.module'
     },
     },
     module: {
     module: {
         loaders: [
         loaders: [

+ 2 - 1
client/webpack.dev.js

@@ -28,7 +28,8 @@ var webpackMerge = require('webpack-merge');
 module.exports = webpackMerge(commonConfig, {
 module.exports = webpackMerge(commonConfig, {
     devtool: 'cheap-module-source-map',
     devtool: 'cheap-module-source-map',
     entry: {
     entry: {
-        'peoplesearch.ng': './src/main.dev'
+        'peoplesearch.ng': './src/main.dev',
+        'changepassword.ng': './src/pages/changepassword/changepassword.module'
     },
     },
     module: {
     module: {
         loaders: [
         loaders: [

+ 1 - 1
server/src/main/resources/password/pwm/i18n/Display.properties

@@ -94,7 +94,7 @@ Display_GuestRegistration=To register a new guest account, please enter the foll
 Display_GuestUpdate=To update a guest account, please check and modify the following information.
 Display_GuestUpdate=To update a guest account, please check and modify the following information.
 Display_Helpdesk=Please enter search data for the user.
 Display_Helpdesk=Please enter search data for the user.
 Display_HelpdeskOtpValidation=Instruct the user to load their mobile authentication app and share the current pass code.
 Display_HelpdeskOtpValidation=Instruct the user to load their mobile authentication app and share the current pass code.
-Display_HelpdeskNoData=The server did not respond with valid results.  This can often be caused from an expired session in another browser tab.  Reloading the page should allow you to log in and try again.
+Display_HelpdeskNoData=The server is not responding properly. A session in another browser window might have expired. Reload the page and log in again.
 Display_Hour=hour
 Display_Hour=hour
 Display_Hours=hours
 Display_Hours=hours
 Display_IdleTimeout=Idle Timeout\:
 Display_IdleTimeout=Idle Timeout\:

+ 10 - 4
server/src/main/webapp/WEB-INF/jsp/changepassword.jsp

@@ -35,7 +35,7 @@
     <jsp:include page="fragment/header-body.jsp">
     <jsp:include page="fragment/header-body.jsp">
         <jsp:param name="pwm.PageName" value="Title_ChangePassword"/>
         <jsp:param name="pwm.PageName" value="Title_ChangePassword"/>
     </jsp:include>
     </jsp:include>
-    <div id="centerbody">
+    <div id="centerbody" ng-app="changepassword.module" ng-controller="ChangePasswordController as $ctrl">
         <div id="page-content-title"><pwm:display key="Title_ChangePassword" displayIfMissing="true"/></div>
         <div id="page-content-title"><pwm:display key="Title_ChangePassword" displayIfMissing="true"/></div>
         <pwm:if test="<%=PwmIfTest.passwordExpired%>">
         <pwm:if test="<%=PwmIfTest.passwordExpired%>">
         <h1><pwm:display key="Display_PasswordExpired"/></h1><br/>
         <h1><pwm:display key="Display_PasswordExpired"/></h1><br/>
@@ -54,6 +54,7 @@
         <% } %>
         <% } %>
         <br/>
         <br/>
         <%@ include file="fragment/message.jsp" %>
         <%@ include file="fragment/message.jsp" %>
+
         <form action="<pwm:current-url/>" method="post" enctype="application/x-www-form-urlencoded" id="changePasswordForm" autocomplete="off">
         <form action="<pwm:current-url/>" method="post" enctype="application/x-www-form-urlencoded" id="changePasswordForm" autocomplete="off">
             <table class="noborder">
             <table class="noborder">
                 <tr>
                 <tr>
@@ -66,7 +67,7 @@
                             <div class="pwm-icon pwm-icon-question-circle icon_button" id="password-guide-icon" style="cursor: pointer; visibility: hidden"></div>
                             <div class="pwm-icon pwm-icon-question-circle icon_button" id="password-guide-icon" style="cursor: pointer; visibility: hidden"></div>
                             <pwm:if test="<%=PwmIfTest.showRandomPasswordGenerator%>">
                             <pwm:if test="<%=PwmIfTest.showRandomPasswordGenerator%>">
                                 &nbsp;&nbsp;
                                 &nbsp;&nbsp;
-                                <div class="pwm-icon pwm-icon-retweet icon_button" id="autogenerate-icon" style="cursor: pointer; visibility: hidden" ></div>
+                                <div class="pwm-icon pwm-icon-retweet icon_button" id="autogenerate-icon" ng-click="$ctrl.doRandomGeneration()" style="cursor: pointer; visibility: hidden" ></div>
                             </pwm:if>
                             </pwm:if>
                         </div>
                         </div>
                         <input type="<pwm:value name="<%=PwmValue.passwordFieldType%>"/>" name="password1" id="password1" class="changepasswordfield passwordfield" <pwm:autofocus/>/>
                         <input type="<pwm:value name="<%=PwmValue.passwordFieldType%>"/>" name="password1" id="password1" class="changepasswordfield passwordfield" <pwm:autofocus/>/>
@@ -133,9 +134,14 @@
         });
         });
     </script>
     </script>
 </pwm:script>
 </pwm:script>
+
+<pwm:script-ref url="/public/resources/webjars/angular/angular.min.js" />
+<pwm:script-ref url="/public/resources/webjars/angular-ui-router/release/angular-ui-router.min.js" />
+<pwm:script-ref url="/public/resources/webjars/angular-translate/dist/angular-translate.min.js" />
+
 <pwm:script-ref url="/public/resources/js/changepassword.js"/>
 <pwm:script-ref url="/public/resources/js/changepassword.js"/>
+<pwm:script-ref url="/public/resources/webjars/pwm-client/changepassword.ng.js" />
+
 <%@ include file="fragment/footer.jsp" %>
 <%@ include file="fragment/footer.jsp" %>
 </body>
 </body>
 </html>
 </html>
-
-

+ 3 - 3
server/src/main/webapp/public/resources/js/changepassword.js

@@ -349,9 +349,9 @@ PWM_CHANGEPW.startupChangePasswordPage=function() {
     var autoGenPasswordElement = PWM_MAIN.getObject("autogenerate-icon");
     var autoGenPasswordElement = PWM_MAIN.getObject("autogenerate-icon");
     if (autoGenPasswordElement !== null) {
     if (autoGenPasswordElement !== null) {
         autoGenPasswordElement.style.visibility = 'visible';
         autoGenPasswordElement.style.visibility = 'visible';
-        PWM_MAIN.addEventHandler(autoGenPasswordElement,'click',function(){
-            PWM_CHANGEPW.doRandomGeneration();
-        });
+        // PWM_MAIN.addEventHandler(autoGenPasswordElement,'click',function(){
+        //     PWM_CHANGEPW.doRandomGeneration();
+        // });
         PWM_MAIN.showTooltip({
         PWM_MAIN.showTooltip({
             id: "autogenerate-icon",
             id: "autogenerate-icon",
             text: PWM_MAIN.showString('Display_AutoGeneratedPassword')
             text: PWM_MAIN.showString('Display_AutoGeneratedPassword')