Jelajahi Sumber

Updated the code to no longer show the new password if the password type is random. Also fixed a NullPointerException in the random password generator.

jalbr74 6 tahun lalu
induk
melakukan
0b6cdc4806

+ 7 - 5
client/src/components/changepassword/success-change-password.component.html

@@ -28,11 +28,13 @@
 
         <div class="ias-dialog-content">
             <p ng-bind="$ctrl.successMessage"></p>
-            <span ng-bind="'Field_NewPassword' | translate"></span>
-            <ias-button ng-click="$ctrl.togglePasswordMasked()" ng-if="$ctrl.maskPasswords">
-                {{ 'Button_Show' | translate }}
-            </ias-button>
-            <input ng-model="$ctrl.password" ng-hide="$ctrl.passwordMasked" readonly type="text" autofocus>
+            <div ng-if="$ctrl.displayNewPassword">
+                <span ng-bind="'Field_NewPassword' | translate"></span>
+                <ias-button ng-click="$ctrl.togglePasswordMasked()" ng-if="$ctrl.maskPasswords">
+                    {{ 'Button_Show' | translate }}
+                </ias-button>
+                <input ng-model="$ctrl.password" ng-hide="$ctrl.passwordMasked" readonly type="text" autofocus>
+            </div>
         </div>
 
         <div class="ias-actions">

+ 7 - 2
client/src/components/changepassword/success-change-password.controller.ts

@@ -23,7 +23,7 @@
 
 import {IHelpDeskService } from '../../services/helpdesk.service';
 import {IQService} from 'angular';
-import {IHelpDeskConfigService} from '../../services/helpdesk-config.service';
+import {IHelpDeskConfigService, PASSWORD_UI_MODES} from '../../services/helpdesk-config.service';
 
 export interface IChangePasswordSuccess {
     password: string;
@@ -36,6 +36,7 @@ export default class SuccessChangePasswordController {
     password: string;
     passwordMasked: boolean;
     successMessage: string;
+    displayNewPassword: boolean;
 
     static $inject = [
         '$q',
@@ -58,12 +59,16 @@ export default class SuccessChangePasswordController {
 
         let promise = this.$q.all([
             this.configService.getClearResponsesSetting(),
-            this.configService.maskPasswordsEnabled()
+            this.configService.maskPasswordsEnabled(),
+            this.configService.getPasswordUiMode()
         ]);
         promise.then((result) => {
             this.clearResponsesSetting = result[0];
             this.maskPasswords = result[1];
             this.passwordMasked = this.maskPasswords;
+
+            // If it's random, don't display the new password
+            this.displayNewPassword = (result[2] !== PASSWORD_UI_MODES.RANDOM);
         });
     }
 

+ 4 - 4
server/src/main/java/password/pwm/util/RandomPasswordGenerator.java

@@ -527,7 +527,7 @@ public class RandomPasswordGenerator
             if ( numChars == null )
             {
                 final StringBuilder sb = new StringBuilder();
-                for ( final Character c : allChars.toCharArray() )
+                for ( final Character c : getAllChars().toCharArray() )
                 {
                     if ( Character.isDigit( c ) )
                     {
@@ -545,7 +545,7 @@ public class RandomPasswordGenerator
             if ( specialChars == null )
             {
                 final StringBuilder sb = new StringBuilder();
-                for ( final Character c : allChars.toCharArray() )
+                for ( final Character c : getAllChars().toCharArray() )
                 {
                     if ( !Character.isLetterOrDigit( c ) )
                     {
@@ -563,7 +563,7 @@ public class RandomPasswordGenerator
             if ( upperChars == null )
             {
                 final StringBuilder sb = new StringBuilder();
-                for ( final Character c : allChars.toCharArray() )
+                for ( final Character c : getAllChars().toCharArray() )
                 {
                     if ( Character.isUpperCase( c ) )
                     {
@@ -580,7 +580,7 @@ public class RandomPasswordGenerator
             if ( lowerChars == null )
             {
                 final StringBuilder sb = new StringBuilder();
-                for ( final Character c : allChars.toCharArray() )
+                for ( final Character c : getAllChars().toCharArray() )
                 {
                     if ( Character.isLowerCase( c ) )
                     {