Bläddra i källkod

after splitting into change password dialogs

Joseph White 7 år sedan
förälder
incheckning
cae01df7a7

+ 20 - 85
client/src/changepassword/autogen-change-password.component.html

@@ -20,93 +20,28 @@
   ~ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   -->
 
-<ias-dialog class="change-password-dialog" ng-switch="$ctrl.status">
-
-    <div ng-switch-when="confirm-random">
-        <div class="ias-dialog-header">
-            <div class="ias-title" ng-bind="('Title_ChangePassword' | translate) + ': ' + $ctrl.personUsername"></div>
-        </div>
-        <div class="ias-dialog-body">
-            <p ng-bind="'Display_SetRandomPasswordPrompt' | translate"></p>
-        </div>
-        <div class="ias-actions">
-            <mf-button ng-click="$ctrl.confirmSetRandomPassword()">{{ 'Button_OK' | translate }}</mf-button>
-            <mf-button ng-click="cancel()">{{ 'Button_Cancel' | translate }}</mf-button>
-        </div>
-    </div>
-
-    <div ng-switch-when="type">
-        <div class="ias-dialog-header">
-            <div class="ias-title" ng-bind="('Title_ChangePassword' | translate) + ' - ' + $ctrl.personUsername"></div>
-        </div>
-        <div class="ias-dialog-body">
-            <p ng-bind="$ctrl.message"></p>
-
-
-            <input ng-model="$ctrl.password1" ng-hide="$ctrl.password1Masked" type="text">
-            <input ng-model="$ctrl.password1" ng-show="$ctrl.password1Masked" type="password">
-            <mf-button ng-click="$ctrl.togglePassword1Masked()" ng-if="$ctrl.maskPasswords">
-                {{ 'Button_Show' | translate }}
-            </mf-button>
-            <span>Strength: Very Strong</span>
-
-            <input ng-model="$ctrl.password2" ng-hide="$ctrl.password2Masked" type="text">
-            <input ng-model="$ctrl.password2" ng-show="$ctrl.password2Masked" type="password">
-            <mf-button ng-click="$ctrl.togglePassword2Masked()" ng-if="$ctrl.maskPasswords">
-                {{ 'Button_Show' | translate }}
-            </mf-button>
-            <!--Password list
-            First pw   strength
-            Second pw  checkmark-->
-        </div>
-        <div class="ias-actions">
-            <mf-button ng-click="$ctrl.chooseTypedPassword()">{{ 'Button_ChangePassword' | translate }}</mf-button>
-            <mf-button ng-click="$ctrl.status = 'autogen'"
-                       ng-if="$ctrl.passwordUiMode === 'BOTH'">{{ 'Title_RandomPasswords' | translate }}</mf-button>
-        </div>
+<ias-dialog class="change-password-dialog">
+    <div class="ias-dialog-header">
+        <div class="ias-title" ng-bind="'Title_RandomPasswords' | translate"></div>
     </div>
-
-    <div ng-switch-when="autogen">
-        <div class="ias-dialog-header">
-            <div class="ias-title" ng-bind="'Title_RandomPasswords' | translate"></div>
-        </div>
-        <div class="ias-dialog-body">
-            <p ng-bind="'Display_PasswordGeneration' | translate"></p>
-            <table>
-                <tbody>
-                <tr ng-repeat="i in [0,2,4,6,8,10,12,14,16,18]">
-                    <td ng-repeat="j in [i, i+1]">
-                        <div ng-bind="$ctrl.passwordSuggestions[j]" ng-click="$ctrl.onChoosePasswordSuggestion(j)">
-                        </div>
-                    </td>
-                </tr>
-                </tbody>
-            </table>
-        </div>
-        <div class="ias-actions">
-            <mf-button ng-click="$ctrl.populatePasswordSuggestions()"
-                       ng-disabled="$ctrl.fetchingRandoms">{{ 'Button_More' | translate }}</mf-button>
-            <mf-button ng-click="cancel()">{{ 'Button_Cancel' | translate }}</mf-button>
-        </div>
+    <div class="ias-dialog-body">
+        <p ng-bind="'Display_PasswordGeneration' | translate"></p>
+        <table>
+            <tbody>
+            <tr ng-repeat="i in [0,2,4,6,8,10,12,14,16,18]">
+                <td ng-repeat="j in [i, i+1]">
+                    <div ng-bind="$ctrl.passwordSuggestions[j]" ng-click="$ctrl.onChoosePasswordSuggestion(j)">
+                    </div>
+                </td>
+            </tr>
+            </tbody>
+        </table>
     </div>
-
-    <div ng-switch-when="finished">
-        <div class="ias-dialog-header">
-            <div class="ias-title" ng-bind="('Title_ChangePassword' | translate) + ' - ' + $ctrl.personUsername"></div>
-        </div>
-        <div class="ias-dialog-body">
-            <p ng-bind="$ctrl.message"></p>
-            <span ng-bind="'Field_NewPassword' | translate"></span>
-            <mf-button ng-click="$ctrl.togglePassword1Masked()" ng-if="$ctrl.maskPasswords">
-                {{ 'Button_Show' | translate }}
-            </mf-button>
-            <input ng-model="$ctrl.chosenPassword" ng-hide="$ctrl.password1Masked" readonly type="text">
-        </div>
-        <div class="ias-actions">
-            <mf-button ng-click="cancel()">{{ 'Button_OK' | translate }}</mf-button>
-            <mf-button ng-click="$ctrl.clearAnswers()"
-                       ng-if="$ctrl.clearResponsesSetting==='ask'">{{ 'Button_ClearResponses' | translate }}</mf-button>
-        </div>
+    <div class="ias-actions">
+        <mf-button ng-click="$ctrl.populatePasswordSuggestions()"
+                   ng-disabled="$ctrl.fetchingRandoms">{{ 'Button_More' | translate }}
+        </mf-button>
+        <mf-button ng-click="cancel()">{{ 'Button_Cancel' | translate }}</mf-button>
     </div>
 
     <mf-icon-button class="ias-dialog-close-button"

+ 0 - 0
client/src/helpdesk/password-suggestions-dialog.scss → client/src/changepassword/autogen-change-password.component.scss


+ 88 - 0
client/src/changepassword/autogen-change-password.controller.ts

@@ -0,0 +1,88 @@
+/*
+ * 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
+ */
+
+
+import {IHelpDeskService, IRandomPasswordResponse, ISuccessResponse} from '../services/helpdesk.service';
+import {IPromise, IQService} from 'angular';
+import DialogService from '../ux/ias-dialog.service';
+import {IChangePasswordSuccess} from './success-change-password.controller';
+
+const RANDOM_MAPPING_SIZE = 20;
+
+require('changepassword/autogen-change-password.component.scss');
+
+export default class AutogenChangePasswordController {
+    fetchingRandoms: boolean;
+    passwordSuggestions: string[];
+
+    static $inject = [ '$q', 'HelpDeskService', 'IasDialogService', 'personUserKey' ];
+    constructor(private $q: IQService,
+                private HelpDeskService: IHelpDeskService,
+                private IasDialogService: DialogService,
+                private personUserKey: string) {
+        this.passwordSuggestions = Array(20).fill('');
+        this.populatePasswordSuggestions();
+    }
+
+    generateRandomMapping(): number[] {
+        let map: number[] = [];
+        for (let i = 0; i < RANDOM_MAPPING_SIZE; i++) {
+            map.push(i);
+        }
+        let randomComparatorFunction = () => 0.5 - Math.random();
+        map.sort(randomComparatorFunction);
+        map.sort(randomComparatorFunction);
+        return map;
+    }
+
+    onChoosePasswordSuggestion(index: number) {
+        let chosenPassword = this.passwordSuggestions[index];
+        this.HelpDeskService.setPassword(this.personUserKey, false, chosenPassword)
+            .then((result: ISuccessResponse) => {
+                // Send the password and success message to the parent element via the close() method.
+                let data: IChangePasswordSuccess = { password: chosenPassword, successMessage: result.successMessage };
+                this.IasDialogService.close(data);
+            });
+    }
+
+    passwordSuggestionFactory(index: number): any {
+        return () => {
+            return this.HelpDeskService.getRandomPassword(this.personUserKey).then(
+                (result: IRandomPasswordResponse) => {
+                    this.passwordSuggestions[index] = result.password;
+                }
+            );
+        };
+    }
+
+    populatePasswordSuggestions() {
+        this.fetchingRandoms = true;
+        let ordering = this.generateRandomMapping();
+        let promiseChain: IPromise<any> = this.$q.when();
+        ordering.forEach((index: number) => {
+            promiseChain = promiseChain.then(this.passwordSuggestionFactory(index));
+        });
+        promiseChain.then(() => {
+            this.fetchingRandoms = false;
+        });
+    }
+}

+ 0 - 1
client/src/changepassword/random-change-password.component.html

@@ -21,7 +21,6 @@
   -->
 
 <ias-dialog class="change-password-dialog">
-
     <div class="ias-dialog-header">
         <div class="ias-title" ng-bind="('Title_ChangePassword' | translate) + ': ' + $ctrl.personUsername"></div>
     </div>

+ 53 - 0
client/src/changepassword/random-change-password.controller.ts

@@ -0,0 +1,53 @@
+/*
+ * 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
+ */
+
+
+import {IHelpDeskService, ISuccessResponse} from '../services/helpdesk.service';
+import DialogService from '../ux/ias-dialog.service';
+import {IChangePasswordSuccess} from './success-change-password.controller';
+
+export default class RandomChangePasswordController {
+
+    static $inject = [
+        'HelpDeskService',
+        'IasDialogService',
+        'personUsername',
+        'personUserKey',
+        'translateFilter'
+    ];
+    constructor(private HelpDeskService: IHelpDeskService,
+                private IasDialogService: DialogService,
+                private personUsername: string,
+                private personUserKey: string,
+                private translateFilter: (id: string) => string) {
+    }
+
+    confirmSetRandomPassword() {
+        this.HelpDeskService.setPassword(this.personUserKey, true)
+            .then((result: ISuccessResponse) => {
+                // Send the password and success message to the parent element via the close() method.
+                let chosenPassword = '[' + this.translateFilter('Display_Random') +  ']';
+                let data: IChangePasswordSuccess = { password: chosenPassword, successMessage: result.successMessage };
+                this.IasDialogService.close(data);
+            });
+    }
+}

+ 15 - 85
client/src/changepassword/success-change-password.component.html

@@ -20,93 +20,23 @@
   ~ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   -->
 
-<ias-dialog class="change-password-dialog" ng-switch="$ctrl.status">
-
-    <div ng-switch-when="confirm-random">
-        <div class="ias-dialog-header">
-            <div class="ias-title" ng-bind="('Title_ChangePassword' | translate) + ': ' + $ctrl.personUsername"></div>
-        </div>
-        <div class="ias-dialog-body">
-            <p ng-bind="'Display_SetRandomPasswordPrompt' | translate"></p>
-        </div>
-        <div class="ias-actions">
-            <mf-button ng-click="$ctrl.confirmSetRandomPassword()">{{ 'Button_OK' | translate }}</mf-button>
-            <mf-button ng-click="cancel()">{{ 'Button_Cancel' | translate }}</mf-button>
-        </div>
-    </div>
-
-    <div ng-switch-when="type">
-        <div class="ias-dialog-header">
-            <div class="ias-title" ng-bind="('Title_ChangePassword' | translate) + ' - ' + $ctrl.personUsername"></div>
-        </div>
-        <div class="ias-dialog-body">
-            <p ng-bind="$ctrl.message"></p>
-
-
-            <input ng-model="$ctrl.password1" ng-hide="$ctrl.password1Masked" type="text">
-            <input ng-model="$ctrl.password1" ng-show="$ctrl.password1Masked" type="password">
-            <mf-button ng-click="$ctrl.togglePassword1Masked()" ng-if="$ctrl.maskPasswords">
-                {{ 'Button_Show' | translate }}
-            </mf-button>
-            <span>Strength: Very Strong</span>
-
-            <input ng-model="$ctrl.password2" ng-hide="$ctrl.password2Masked" type="text">
-            <input ng-model="$ctrl.password2" ng-show="$ctrl.password2Masked" type="password">
-            <mf-button ng-click="$ctrl.togglePassword2Masked()" ng-if="$ctrl.maskPasswords">
-                {{ 'Button_Show' | translate }}
-            </mf-button>
-            <!--Password list
-            First pw   strength
-            Second pw  checkmark-->
-        </div>
-        <div class="ias-actions">
-            <mf-button ng-click="$ctrl.chooseTypedPassword()">{{ 'Button_ChangePassword' | translate }}</mf-button>
-            <mf-button ng-click="$ctrl.status = 'autogen'"
-                       ng-if="$ctrl.passwordUiMode === 'BOTH'">{{ 'Title_RandomPasswords' | translate }}</mf-button>
-        </div>
+<ias-dialog class="change-password-dialog">
+    <div class="ias-dialog-header">
+        <div class="ias-title" ng-bind="('Title_ChangePassword' | translate) + ' - ' + $ctrl.personUsername"></div>
     </div>
-
-    <div ng-switch-when="autogen">
-        <div class="ias-dialog-header">
-            <div class="ias-title" ng-bind="'Title_RandomPasswords' | translate"></div>
-        </div>
-        <div class="ias-dialog-body">
-            <p ng-bind="'Display_PasswordGeneration' | translate"></p>
-            <table>
-                <tbody>
-                <tr ng-repeat="i in [0,2,4,6,8,10,12,14,16,18]">
-                    <td ng-repeat="j in [i, i+1]">
-                        <div ng-bind="$ctrl.passwordSuggestions[j]" ng-click="$ctrl.onChoosePasswordSuggestion(j)">
-                        </div>
-                    </td>
-                </tr>
-                </tbody>
-            </table>
-        </div>
-        <div class="ias-actions">
-            <mf-button ng-click="$ctrl.populatePasswordSuggestions()"
-                       ng-disabled="$ctrl.fetchingRandoms">{{ 'Button_More' | translate }}</mf-button>
-            <mf-button ng-click="cancel()">{{ 'Button_Cancel' | translate }}</mf-button>
-        </div>
+    <div class="ias-dialog-body">
+        <p ng-bind="$ctrl.successMessage"></p>
+        <span ng-bind="'Field_NewPassword' | translate"></span>
+        <mf-button ng-click="$ctrl.togglePasswordMasked()" ng-if="$ctrl.maskPasswords">
+            {{ 'Button_Show' | translate }}
+        </mf-button>
+        <input ng-model="$ctrl.password" ng-hide="$ctrl.passwordMasked" readonly type="text">
     </div>
-
-    <div ng-switch-when="finished">
-        <div class="ias-dialog-header">
-            <div class="ias-title" ng-bind="('Title_ChangePassword' | translate) + ' - ' + $ctrl.personUsername"></div>
-        </div>
-        <div class="ias-dialog-body">
-            <p ng-bind="$ctrl.message"></p>
-            <span ng-bind="'Field_NewPassword' | translate"></span>
-            <mf-button ng-click="$ctrl.togglePassword1Masked()" ng-if="$ctrl.maskPasswords">
-                {{ 'Button_Show' | translate }}
-            </mf-button>
-            <input ng-model="$ctrl.chosenPassword" ng-hide="$ctrl.password1Masked" readonly type="text">
-        </div>
-        <div class="ias-actions">
-            <mf-button ng-click="cancel()">{{ 'Button_OK' | translate }}</mf-button>
-            <mf-button ng-click="$ctrl.clearAnswers()"
-                       ng-if="$ctrl.clearResponsesSetting==='ask'">{{ 'Button_ClearResponses' | translate }}</mf-button>
-        </div>
+    <div class="ias-actions">
+        <mf-button ng-click="cancel()">{{ 'Button_OK' | translate }}</mf-button>
+        <mf-button ng-click="$ctrl.clearAnswers()"
+                   ng-if="$ctrl.clearResponsesSetting==='ask'">{{ 'Button_ClearResponses' | translate }}
+        </mf-button>
     </div>
 
     <mf-icon-button class="ias-dialog-close-button"

+ 80 - 0
client/src/changepassword/success-change-password.controller.ts

@@ -0,0 +1,80 @@
+/*
+ * 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
+ */
+
+
+import {IHelpDeskService } from '../services/helpdesk.service';
+import {IQService} from 'angular';
+import {IHelpDeskConfigService} from '../services/helpdesk-config.service';
+import DialogService from '../ux/ias-dialog.service';
+
+export interface IChangePasswordSuccess {
+    password: string;
+    successMessage: string;
+}
+
+export default class SuccessChangePasswordController {
+    clearResponsesSetting: string;
+    maskPasswords: boolean;
+    password: string;
+    passwordMasked: boolean;
+    successMessage: string;
+
+    static $inject = [
+        '$q',
+        'changePasswordSuccessData',
+        'ConfigService',
+        'HelpDeskService',
+        'IasDialogService',
+        'personUsername',
+        'personUserKey',
+        'translateFilter'
+    ];
+    constructor(private $q: IQService,
+                changePasswordSuccessData: IChangePasswordSuccess,
+                private configService: IHelpDeskConfigService,
+                private HelpDeskService: IHelpDeskService,
+                private IasDialogService: DialogService,
+                private personUsername: string,
+                private personUserKey: string,
+                private translateFilter: (id: string) => string) {
+        this.password = changePasswordSuccessData.password;
+        this.successMessage = changePasswordSuccessData.successMessage;
+
+        let promise = this.$q.all([
+            this.configService.getClearResponsesSetting(),
+            this.configService.maskPasswordsEnabled()
+        ]);
+        promise.then((result) => {
+            this.clearResponsesSetting = result[0];
+            this.maskPasswords = result[1];
+            this.passwordMasked = this.maskPasswords;
+        });
+    }
+
+    clearAnswers() {
+        this.IasDialogService.close();
+    }
+
+    togglePasswordMasked() {
+        this.passwordMasked = !this.passwordMasked;
+    }
+}

+ 27 - 85
client/src/changepassword/type-change-password.component.html

@@ -20,93 +20,35 @@
   ~ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   -->
 
-<ias-dialog class="change-password-dialog" ng-switch="$ctrl.status">
-
-    <div ng-switch-when="confirm-random">
-        <div class="ias-dialog-header">
-            <div class="ias-title" ng-bind="('Title_ChangePassword' | translate) + ': ' + $ctrl.personUsername"></div>
-        </div>
-        <div class="ias-dialog-body">
-            <p ng-bind="'Display_SetRandomPasswordPrompt' | translate"></p>
-        </div>
-        <div class="ias-actions">
-            <mf-button ng-click="$ctrl.confirmSetRandomPassword()">{{ 'Button_OK' | translate }}</mf-button>
-            <mf-button ng-click="cancel()">{{ 'Button_Cancel' | translate }}</mf-button>
-        </div>
-    </div>
-
-    <div ng-switch-when="type">
-        <div class="ias-dialog-header">
-            <div class="ias-title" ng-bind="('Title_ChangePassword' | translate) + ' - ' + $ctrl.personUsername"></div>
-        </div>
-        <div class="ias-dialog-body">
-            <p ng-bind="$ctrl.message"></p>
-
-
-            <input ng-model="$ctrl.password1" ng-hide="$ctrl.password1Masked" type="text">
-            <input ng-model="$ctrl.password1" ng-show="$ctrl.password1Masked" type="password">
-            <mf-button ng-click="$ctrl.togglePassword1Masked()" ng-if="$ctrl.maskPasswords">
-                {{ 'Button_Show' | translate }}
-            </mf-button>
-            <span>Strength: Very Strong</span>
-
-            <input ng-model="$ctrl.password2" ng-hide="$ctrl.password2Masked" type="text">
-            <input ng-model="$ctrl.password2" ng-show="$ctrl.password2Masked" type="password">
-            <mf-button ng-click="$ctrl.togglePassword2Masked()" ng-if="$ctrl.maskPasswords">
-                {{ 'Button_Show' | translate }}
-            </mf-button>
-            <!--Password list
-            First pw   strength
-            Second pw  checkmark-->
-        </div>
-        <div class="ias-actions">
-            <mf-button ng-click="$ctrl.chooseTypedPassword()">{{ 'Button_ChangePassword' | translate }}</mf-button>
-            <mf-button ng-click="$ctrl.status = 'autogen'"
-                       ng-if="$ctrl.passwordUiMode === 'BOTH'">{{ 'Title_RandomPasswords' | translate }}</mf-button>
-        </div>
+<ias-dialog class="change-password-dialog">
+    <div class="ias-dialog-header">
+        <div class="ias-title" ng-bind="('Title_ChangePassword' | translate) + ' - ' + $ctrl.personUsername"></div>
     </div>
-
-    <div ng-switch-when="autogen">
-        <div class="ias-dialog-header">
-            <div class="ias-title" ng-bind="'Title_RandomPasswords' | translate"></div>
-        </div>
-        <div class="ias-dialog-body">
-            <p ng-bind="'Display_PasswordGeneration' | translate"></p>
-            <table>
-                <tbody>
-                <tr ng-repeat="i in [0,2,4,6,8,10,12,14,16,18]">
-                    <td ng-repeat="j in [i, i+1]">
-                        <div ng-bind="$ctrl.passwordSuggestions[j]" ng-click="$ctrl.onChoosePasswordSuggestion(j)">
-                        </div>
-                    </td>
-                </tr>
-                </tbody>
-            </table>
-        </div>
-        <div class="ias-actions">
-            <mf-button ng-click="$ctrl.populatePasswordSuggestions()"
-                       ng-disabled="$ctrl.fetchingRandoms">{{ 'Button_More' | translate }}</mf-button>
-            <mf-button ng-click="cancel()">{{ 'Button_Cancel' | translate }}</mf-button>
-        </div>
+    <div class="ias-dialog-body">
+        <p ng-bind="$ctrl.message"></p>
+
+
+        <input ng-model="$ctrl.password1" ng-hide="$ctrl.password1Masked" type="text">
+        <input ng-model="$ctrl.password1" ng-show="$ctrl.password1Masked" type="password">
+        <mf-button ng-click="$ctrl.togglePassword1Masked()" ng-if="$ctrl.maskPasswords">
+            {{ 'Button_Show' | translate }}
+        </mf-button>
+        <span>Strength: Very Strong</span>
+
+        <input ng-model="$ctrl.password2" ng-hide="$ctrl.password2Masked" type="text">
+        <input ng-model="$ctrl.password2" ng-show="$ctrl.password2Masked" type="password">
+        <mf-button ng-click="$ctrl.togglePassword2Masked()" ng-if="$ctrl.maskPasswords">
+            {{ 'Button_Show' | translate }}
+        </mf-button>
+        <!--Password list
+        First pw   strength
+        Second pw  checkmark-->
     </div>
-
-    <div ng-switch-when="finished">
-        <div class="ias-dialog-header">
-            <div class="ias-title" ng-bind="('Title_ChangePassword' | translate) + ' - ' + $ctrl.personUsername"></div>
-        </div>
-        <div class="ias-dialog-body">
-            <p ng-bind="$ctrl.message"></p>
-            <span ng-bind="'Field_NewPassword' | translate"></span>
-            <mf-button ng-click="$ctrl.togglePassword1Masked()" ng-if="$ctrl.maskPasswords">
-                {{ 'Button_Show' | translate }}
-            </mf-button>
-            <input ng-model="$ctrl.chosenPassword" ng-hide="$ctrl.password1Masked" readonly type="text">
-        </div>
-        <div class="ias-actions">
-            <mf-button ng-click="cancel()">{{ 'Button_OK' | translate }}</mf-button>
-            <mf-button ng-click="$ctrl.clearAnswers()"
-                       ng-if="$ctrl.clearResponsesSetting==='ask'">{{ 'Button_ClearResponses' | translate }}</mf-button>
-        </div>
+    <div class="ias-actions">
+        <mf-button ng-click="$ctrl.chooseTypedPassword()">{{ 'Button_ChangePassword' | translate }}</mf-button>
+        <mf-button ng-click="$ctrl.status = 'autogen'"
+                   ng-if="$ctrl.passwordUiMode === 'BOTH'">{{ 'Title_RandomPasswords' | translate }}
+        </mf-button>
     </div>
 
     <mf-icon-button class="ias-dialog-close-button"

+ 89 - 0
client/src/changepassword/type-change-password.controller.ts

@@ -0,0 +1,89 @@
+/*
+ * 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
+ */
+
+
+import {IHelpDeskService, ISuccessResponse} from '../services/helpdesk.service';
+import {IQService} from 'angular';
+import {IHelpDeskConfigService} from '../services/helpdesk-config.service';
+import DialogService from '../ux/ias-dialog.service';
+import {IChangePasswordSuccess} from './success-change-password.controller';
+
+export default class TypeChangePasswordController {
+    chosenPassword: string;
+    maskPasswords: boolean;
+    message: string;
+    password1: string;
+    password2: string;
+    password1Masked: boolean;
+    password2Masked: boolean;
+    passwordSuggestions: string[];
+    // this.HelpDeskService.showStrengthMeter;
+
+    static $inject = [
+        '$q',
+        'ConfigService',
+        'HelpDeskService',
+        'IasDialogService',
+        'personUsername',
+        'personUserKey',
+        'translateFilter'
+    ];
+    constructor(private $q: IQService,
+                private configService: IHelpDeskConfigService,
+                private HelpDeskService: IHelpDeskService,
+                private IasDialogService: DialogService,
+                private personUsername: string,
+                private personUserKey: string,
+                private translateFilter: (id: string) => string) {
+        this.passwordSuggestions = Array(20).fill('');
+        this.message = translateFilter('Display_PasswordPrompt');
+
+        this.configService.maskPasswordsEnabled()
+            .then((maskPasswords: boolean) => {
+                this.maskPasswords = maskPasswords;
+                this.password1Masked = this.maskPasswords;
+                this.password2Masked = this.maskPasswords;
+            });
+    }
+
+    chooseTypedPassword() {     // todo: should this be merged with onChoosePasswordSuggestion?
+        this.HelpDeskService.setPassword(this.personUserKey, false, this.chosenPassword)
+            .then((result: ISuccessResponse) => {
+                // Send the password and success message to the parent element via the close() method.
+                let data: IChangePasswordSuccess = { password: this.password1, successMessage: result.successMessage };
+                this.IasDialogService.close(data);
+            });
+    }
+
+    // Use the autogenPasswords property to signify to the parent element that the operator clicked "Random Passwords"
+    onClickRandomPasswords() {
+        this.IasDialogService.close({ autogenPasswords: true });
+    }
+
+    togglePassword1Masked() {
+        this.password1Masked = !this.password1Masked;
+    }
+
+    togglePassword2Masked() {
+        this.password2Masked = !this.password2Masked;
+    }
+}

+ 106 - 30
client/src/helpdesk/helpdesk-detail.component.ts

@@ -24,15 +24,19 @@
 import {Component} from '../component';
 import {IButtonInfo, IHelpDeskService, ISuccessResponse} from '../services/helpdesk.service';
 import {IScope, ui} from '@types/angular';
-import {noop} from 'angular';
-import {IActionButtons, IHelpDeskConfigService} from '../services/helpdesk-config.service';
+import {IQService, noop} from 'angular';
+import {IActionButtons, IHelpDeskConfigService, PASSWORD_UI_MODES} from '../services/helpdesk-config.service';
 import DialogService from '../ux/ias-dialog.service';
 import {IPeopleService} from '../services/people.service';
 import {IPerson} from '../models/person.model';
 import IasDialogComponent from '../ux/ias-dialog.component';
+import {IChangePasswordSuccess} from '../changepassword/success-change-password.controller';
 
+let autogenChangePasswordTemplateUrl = require('changepassword/autogen-change-password.component.html');
 let helpdeskDetailDialogTemplateUrl = require('./helpdesk-detail-dialog.template.html');
-let passwordSuggestionsDialogTemplateUrl = require('./change-password-dialog.html');
+let randomChangePasswordTemplateUrl = require('changepassword/random-change-password.component.html');
+let successChangePasswordTemplateUrl = require('changepassword/success-change-password.component.html');
+let typeChangePasswordTemplateUrl = require('changepassword/type-change-password.component.html');
 let verificationsDialogTemplateUrl = require('./verifications-dialog.template.html');
 
 const STATUS_WAIT = 'wait';
@@ -49,6 +53,7 @@ export default class HelpDeskDetailComponent {
     photosEnabled: boolean;
 
     static $inject = [
+        '$q',
         '$state',
         '$stateParams',
         'ConfigService',
@@ -56,7 +61,8 @@ export default class HelpDeskDetailComponent {
         'IasDialogService',
         'PeopleService'
     ];
-    constructor(private $state: ui.IStateService,
+    constructor(private $q: IQService,
+                private $state: ui.IStateService,
                 private $stateParams: ui.IStateParamsService,
                 private configService: IHelpDeskConfigService,
                 private helpDeskService: IHelpDeskService,
@@ -85,38 +91,108 @@ export default class HelpDeskDetailComponent {
     }
 
     changePassword(): void {
+        this.configService.getPasswordUiMode()
+            .then((passwordUiMode) => {
+                if (passwordUiMode === PASSWORD_UI_MODES.AUTOGEN) {
+                    this.changePasswordAutogen();
+                }
+                else if (passwordUiMode === PASSWORD_UI_MODES.RANDOM) {
+                    this.changePasswordRandom();
+                }
+                else if (passwordUiMode === PASSWORD_UI_MODES.BOTH || passwordUiMode === PASSWORD_UI_MODES.TYPE) {
+                    this.changePasswordType();
+                }
+                else {
+                    throw new Error('Password type unsupported!');  // TODO: best way to do this?
+                }
+            });
+    }
+
+    changePasswordAutogen() {
+        this.IasDialogService
+            .open({
+                controller: 'AutogenChangePasswordController as $ctrl',
+                templateUrl: autogenChangePasswordTemplateUrl,
+                locals: {
+                    personUserKey: this.getUserKey()
+                }
+            })
+            // If the password was changed, the promise resolves. IasDialogService passes the data intact.
+            .then(this.changePasswordSuccess.bind(this), noop);
+    }
+
+    changePasswordClearResponses() {
+        let userKey = this.getUserKey();
+
+        this.IasDialogService
+            .open({
+                controller: [
+                    '$scope',
+                    'HelpDeskService',
+                    'translateFilter',
+                    function ($scope: IScope,
+                              helpDeskService: IHelpDeskService,
+                              translateFilter: (id: string) => string) {
+                        $scope.status = STATUS_WAIT;
+                        $scope.title = translateFilter('Button_ClearResponses');
+                        helpDeskService.clearResponses(userKey).then((data: ISuccessResponse) => {
+                            // TODO - error dialog?
+                            $scope.status = STATUS_SUCCESS;
+                            $scope.text = data.successMessage;
+                        });
+                    }
+                ],
+                templateUrl: helpdeskDetailDialogTemplateUrl
+            });
+    }
+
+    changePasswordRandom() {
         this.IasDialogService
             .open({
-                controller: 'PasswordSuggestionsDialogController as $ctrl',
-                templateUrl: passwordSuggestionsDialogTemplateUrl,
+                controller: 'RandomChangePasswordController as $ctrl',
+                templateUrl: randomChangePasswordTemplateUrl,
                 locals: {
                     personUsername: this.person.userDisplayName,
-                    personUserKey: this.getUserKey(),
+                    personUserKey: this.getUserKey()
                 }
             })
-            .then(() => {
-                let userKey = this.getUserKey();
-
-                this.IasDialogService
-                    .open({
-                        controller: [
-                            '$scope',
-                            'HelpDeskService',
-                            'translateFilter',
-                            function ($scope: IScope,
-                                      helpDeskService: IHelpDeskService,
-                                      translateFilter: (id: string) => string) {
-                                $scope.status = STATUS_WAIT;
-                                $scope.title = translateFilter('Button_ClearResponses');
-                                helpDeskService.clearResponses(userKey).then((data: ISuccessResponse) => {
-                                    // TODO - error dialog?
-                                    $scope.status = STATUS_SUCCESS;
-                                    $scope.text = data.successMessage;
-                                });
-                            }
-                        ],
-                        templateUrl: helpdeskDetailDialogTemplateUrl
-                    });
+            // If the password was changed, the promise resolves. IasDialogService passes the data intact.
+            .then(this.changePasswordSuccess.bind(this), noop);
+    }
+
+    changePasswordSuccess(data: IChangePasswordSuccess) {
+        this.IasDialogService
+            .open({
+                controller: 'SuccessChangePasswordController as $ctrl',
+                templateUrl: successChangePasswordTemplateUrl,
+                locals: {
+                    changePasswordSuccessData: data,
+                    personUsername: this.person.userDisplayName,
+                    personUserKey: this.getUserKey()
+                }
+            })
+            .then(this.changePasswordClearResponses.bind(this), noop);
+    }
+
+    changePasswordType() {
+        this.IasDialogService
+            .open({
+                controller: 'TypeChangePasswordController as $ctrl',
+                templateUrl: typeChangePasswordTemplateUrl,
+                locals: {
+                    personUsername: this.person.userDisplayName,
+                    personUserKey: this.getUserKey()
+                }
+            })          // TODO: right data type?
+            // If the operator clicked "Random Passwords" or the password was changed, the promise resolves.
+            .then((data: IChangePasswordSuccess & { autogenPasswords: boolean }) => {
+                // If the operator clicked "Random Passwords", data.autogenPasswords will be true
+                if (data.autogenPasswords) {
+                    this.changePasswordAutogen();
+                }
+                else {
+                    this.changePasswordSuccess(data);   // IasDialogService passes the data intact.
+                }
             }, noop);
     }
 

+ 8 - 2
client/src/helpdesk/helpdesk.module.ts

@@ -27,12 +27,15 @@ import HelpDeskDetailComponent from './helpdesk-detail.component';
 import HelpDeskSearchComponent from './helpdesk-search.component';
 import LocalStorageService from '../services/local-storage.service';
 import ObjectService from '../services/object.service';
-import PasswordSuggestionsDialogController from './password-suggestions.controller';
 import PersonCardComponent from '../peoplesearch/person-card.component';
 import PromiseService from '../services/promise.service';
 import RecentVerificationsDialogController from './recent-verifications-dialog.controller';
 import uxModule from '../ux/ux.module';
 import VerificationsDialogController from './verifications-dialog.controller';
+import AutogenChangePasswordController from '../changepassword/autogen-change-password.controller';
+import RandomChangePasswordController from '../changepassword/random-change-password.controller';
+import SuccessChangePasswordController from '../changepassword/success-change-password.controller';
+import TypeChangePasswordController from '../changepassword/type-change-password.controller';
 
 require('../peoplesearch/peoplesearch.scss');
 
@@ -45,8 +48,11 @@ module(moduleName, [
     .component('helpDeskSearch', HelpDeskSearchComponent)
     .component('helpDeskDetail', HelpDeskDetailComponent)
     .component('personCard', PersonCardComponent)
-    .controller('PasswordSuggestionsDialogController', PasswordSuggestionsDialogController)
+    .controller('AutogenChangePasswordController', AutogenChangePasswordController)
+    .controller('RandomChangePasswordController', RandomChangePasswordController)
     .controller('RecentVerificationsDialogController', RecentVerificationsDialogController)
+    .controller('SuccessChangePasswordController', SuccessChangePasswordController)
+    .controller('TypeChangePasswordController', TypeChangePasswordController)
     .controller('VerificationsDialogController', VerificationsDialogController)
     .filter('dateFilter', DateFilter)
     .service('ObjectService', ObjectService)

+ 0 - 118
client/src/helpdesk/password-suggestions-dialog.html

@@ -1,118 +0,0 @@
-<!--
-  ~ 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
-  -->
-
-<ias-dialog class="change-password-dialog" ng-switch="$ctrl.status">
-
-    <div ng-switch-when="confirm-random">
-        <div class="ias-dialog-header">
-            <div class="ias-title" ng-bind="('Title_ChangePassword' | translate) + ': ' + $ctrl.personUsername"></div>
-        </div>
-        <div class="ias-dialog-body">
-            <p ng-bind="'Display_SetRandomPasswordPrompt' | translate"></p>
-        </div>
-        <div class="ias-actions">
-            <mf-button ng-click="$ctrl.confirmSetRandomPassword()">{{ 'Button_OK' | translate }}</mf-button>
-            <mf-button ng-click="cancel()">{{ 'Button_Cancel' | translate }}</mf-button>
-        </div>
-    </div>
-
-    <div ng-switch-when="type">
-        <div class="ias-dialog-header">
-            <div class="ias-title" ng-bind="('Title_ChangePassword' | translate) + ' - ' + $ctrl.personUsername"></div>
-        </div>
-        <div class="ias-dialog-body">
-            <p ng-bind="$ctrl.message"></p>
-
-
-            <input ng-model="$ctrl.password1" ng-hide="$ctrl.password1Masked" type="text">
-            <input ng-model="$ctrl.password1" ng-show="$ctrl.password1Masked" type="password">
-            <mf-button ng-click="$ctrl.togglePassword1Masked()" ng-if="$ctrl.maskPasswords">
-                {{ 'Button_Show' | translate }}
-            </mf-button>
-            <span>Strength: Very Strong</span>
-
-            <input ng-model="$ctrl.password2" ng-hide="$ctrl.password2Masked" type="text">
-            <input ng-model="$ctrl.password2" ng-show="$ctrl.password2Masked" type="password">
-            <mf-button ng-click="$ctrl.togglePassword2Masked()" ng-if="$ctrl.maskPasswords">
-                {{ 'Button_Show' | translate }}
-            </mf-button>
-            <!--Password list
-            First pw   strength
-            Second pw  checkmark-->
-        </div>
-        <div class="ias-actions">
-            <mf-button ng-click="$ctrl.chooseTypedPassword()">{{ 'Button_ChangePassword' | translate }}</mf-button>
-            <mf-button ng-click="$ctrl.status = 'autogen'"
-                       ng-if="$ctrl.passwordUiMode === 'BOTH'">{{ 'Title_RandomPasswords' | translate }}</mf-button>
-        </div>
-    </div>
-
-    <div ng-switch-when="autogen">
-        <div class="ias-dialog-header">
-            <div class="ias-title" ng-bind="'Title_RandomPasswords' | translate"></div>
-        </div>
-        <div class="ias-dialog-body">
-            <p ng-bind="'Display_PasswordGeneration' | translate"></p>
-            <table>
-                <tbody>
-                <tr ng-repeat="i in [0,2,4,6,8,10,12,14,16,18]">
-                    <td ng-repeat="j in [i, i+1]">
-                        <div ng-bind="$ctrl.passwordSuggestions[j]" ng-click="$ctrl.onChoosePasswordSuggestion(j)">
-                        </div>
-                    </td>
-                </tr>
-                </tbody>
-            </table>
-        </div>
-        <div class="ias-actions">
-            <mf-button ng-click="$ctrl.populatePasswordSuggestions()"
-                       ng-disabled="$ctrl.fetchingRandoms">{{ 'Button_More' | translate }}</mf-button>
-            <mf-button ng-click="cancel()">{{ 'Button_Cancel' | translate }}</mf-button>
-        </div>
-    </div>
-
-    <div ng-switch-when="finished">
-        <div class="ias-dialog-header">
-            <div class="ias-title" ng-bind="('Title_ChangePassword' | translate) + ' - ' + $ctrl.personUsername"></div>
-        </div>
-        <div class="ias-dialog-body">
-            <p ng-bind="$ctrl.message"></p>
-            <span ng-bind="'Field_NewPassword' | translate"></span>
-            <mf-button ng-click="$ctrl.togglePassword1Masked()" ng-if="$ctrl.maskPasswords">
-                {{ 'Button_Show' | translate }}
-            </mf-button>
-            <input ng-model="$ctrl.chosenPassword" ng-hide="$ctrl.password1Masked" readonly type="text">
-        </div>
-        <div class="ias-actions">
-            <mf-button ng-click="cancel()">{{ 'Button_OK' | translate }}</mf-button>
-            <mf-button ng-click="$ctrl.clearAnswers()"
-                       ng-if="$ctrl.clearResponsesSetting==='ask'">{{ 'Button_ClearResponses' | translate }}</mf-button>
-        </div>
-    </div>
-
-    <mf-icon-button class="ias-dialog-close-button"
-                    icon="close_thick"
-                    id="close-icon"
-                    ng-attr-title="{{ 'Button_CloseWindow' | translate }}"
-                    ng-click="cancel()">
-    </mf-icon-button>
-</ias-dialog>

+ 0 - 168
client/src/helpdesk/password-suggestions.controller.ts

@@ -1,168 +0,0 @@
-/*
- * 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
- */
-
-
-import {IHelpDeskService, IRandomPasswordResponse, ISuccessResponse} from '../services/helpdesk.service';
-import {IPromise, IQService} from 'angular';
-import {IHelpDeskConfigService, PASSWORD_UI_MODES} from '../services/helpdesk-config.service';
-import DialogService from '../ux/ias-dialog.service';
-
-const RANDOM_MAPPING_SIZE = 20;
-const STATUS_AUTOGEN = 'autogen';
-const STATUS_CONFIRM_RANDOM = 'confirm-random';
-const STATUS_FINISHED = 'finished';
-const STATUS_TYPE = 'type';
-
-require('helpdesk/change-password-dialog.scss');
-
-export default class PasswordSuggestionsDialogController {
-    chosenPassword: string;
-    clearResponsesSetting: string;
-    fetchingRandoms: boolean;
-    maskPasswords: boolean;
-    message: string;
-    password1: string;
-    password2: string;
-    password1Masked: boolean;
-    password2Masked: boolean;
-    passwordSuggestions: string[];
-    passwordUiMode: string;
-    status: string;
-    // this.HelpDeskService.showStrengthMeter;
-
-    static $inject = [
-        '$q',
-        'ConfigService',
-        'HelpDeskService',
-        'IasDialogService',
-        'personUsername',
-        'personUserKey',
-        'translateFilter'
-    ];
-    constructor(private $q: IQService,
-                private configService: IHelpDeskConfigService,
-                private HelpDeskService: IHelpDeskService,
-                private IasDialogService: DialogService,
-                private personUsername: string,
-                private personUserKey: string,
-                private translateFilter: (id: string) => string) {
-        this.passwordSuggestions = Array(20).fill('');
-
-        let promise = this.$q.all([
-            this.configService.getClearResponsesSetting(),
-            this.configService.getPasswordUiMode(),
-            this.configService.maskPasswordsEnabled()
-        ]);
-        promise.then((result) => {
-            this.clearResponsesSetting = result[0];
-            this.passwordUiMode = result[1];
-            this.maskPasswords = result[2];
-            this.password1Masked = this.maskPasswords;   // Set now instead of later
-            this.password2Masked = this.maskPasswords;
-            if (this.passwordUiMode === PASSWORD_UI_MODES.AUTOGEN) {
-                this.status = STATUS_AUTOGEN;
-                this.populatePasswordSuggestions();
-            }
-            else if (this.passwordUiMode === PASSWORD_UI_MODES.RANDOM) {
-                this.status = STATUS_CONFIRM_RANDOM;
-            }
-            else if (this.passwordUiMode === PASSWORD_UI_MODES.BOTH || this.passwordUiMode === PASSWORD_UI_MODES.TYPE) {
-                this.message = translateFilter('Display_PasswordPrompt');
-                this.status = STATUS_TYPE;
-            }
-            else {
-                throw new Error('Password type unsupported!');  // TODO: best way to do this?
-            }
-        });
-    }
-
-    chooseTypedPassword() {     // todo: should this be merged with onChoosePasswordSuggestion?
-        this.HelpDeskService.setPassword(this.personUserKey, false, this.chosenPassword)
-            .then((result: ISuccessResponse) => {
-                this.status = STATUS_FINISHED;
-                this.message = result.successMessage;
-            });
-    }
-
-    clearAnswers() {
-        this.IasDialogService.close();
-    }
-
-    confirmSetRandomPassword() {
-        this.HelpDeskService.setPassword(this.personUserKey, true)
-            .then((result: ISuccessResponse) => {
-                this.chosenPassword = '[' + this.translateFilter('Display_Random') +  ']';
-                this.status = STATUS_FINISHED;
-                this.message = result.successMessage;
-            });
-    }
-
-    generateRandomMapping(): number[] {
-        let map: number[] = [];
-        for (let i = 0; i < RANDOM_MAPPING_SIZE; i++) {
-            map.push(i);
-        }
-        let randomComparatorFunction = () => 0.5 - Math.random();
-        map.sort(randomComparatorFunction);
-        map.sort(randomComparatorFunction);
-        return map;
-    }
-
-    onChoosePasswordSuggestion(index: number) {
-        this.chosenPassword = this.passwordSuggestions[index];
-        this.HelpDeskService.setPassword(this.personUserKey, false, this.chosenPassword)
-            .then((result: ISuccessResponse) => {
-                this.status = STATUS_FINISHED;
-                this.message = result.successMessage;
-            });
-    }
-
-    passwordSuggestionFactory(index: number): any {
-        return () => {
-            return this.HelpDeskService.getRandomPassword(this.personUserKey).then(
-                (result: IRandomPasswordResponse) => {
-                    this.passwordSuggestions[index] = result.password;
-                }
-            );
-        };
-    }
-
-    populatePasswordSuggestions() {
-        this.fetchingRandoms = true;
-        let ordering = this.generateRandomMapping();
-        let promiseChain: IPromise<any> = this.$q.when();
-        ordering.forEach((index: number) => {
-            promiseChain = promiseChain.then(this.passwordSuggestionFactory(index));
-        });
-        promiseChain.then(() => {
-            this.fetchingRandoms = false;
-        });
-    }
-
-    togglePassword1Masked() {
-        this.password1Masked = !this.password1Masked;
-    }
-
-    togglePassword2Masked() {
-        this.password2Masked = !this.password2Masked;
-    }
-}

+ 1 - 1
client/src/services/helpdesk-config.service.dev.ts

@@ -53,7 +53,7 @@ export default class HelpDeskConfigService extends ConfigBaseService implements
     }
 
     getPasswordUiMode(): IPromise<string> {
-        return this.$q.resolve(PASSWORD_UI_MODES.BOTH);
+        return this.$q.resolve(PASSWORD_UI_MODES.TYPE);
     }
 
     getTokenSendMethod(): IPromise<string> {