17
17
18
18
import { GetPasswordPolicyResponse } from '../../api/password_policy/get_password_policy' ;
19
19
import {
20
+ PasswordPolicyCustomStrengthOptions ,
20
21
PasswordPolicyInternal ,
21
22
PasswordValidationStatusInternal
22
23
} from '../../model/password_policy' ;
@@ -28,41 +29,38 @@ import { PasswordValidationStatus } from '../../model/public_types';
28
29
* @internal
29
30
*/
30
31
export class PasswordPolicyImpl implements PasswordPolicyInternal {
31
- readonly customStrengthOptions : {
32
- readonly minPasswordLength ?: number ;
33
- readonly maxPasswordLength ?: number ;
34
- readonly containsLowercaseLetter ?: boolean ;
35
- readonly containsUppercaseLetter ?: boolean ;
36
- readonly containsNumericCharacter ?: boolean ;
37
- readonly containsNonAlphanumericCharacter ?: boolean ;
38
- } ;
32
+ readonly customStrengthOptions : PasswordPolicyCustomStrengthOptions ;
39
33
readonly allowedNonAlphanumericCharacters ?: string [ ] ;
40
34
readonly schemaVersion : number ;
41
35
42
36
constructor ( response : GetPasswordPolicyResponse ) {
43
37
// Only include custom strength options defined in the response.
44
38
const responseOptions = response . customStrengthOptions ;
45
- this . customStrengthOptions = {
46
- ...( responseOptions . minPasswordLength && {
47
- minPasswordLength : responseOptions . minPasswordLength
48
- } ) ,
49
- ...( responseOptions . maxPasswordLength && {
50
- maxPasswordLength : responseOptions . maxPasswordLength
51
- } ) ,
52
- ...( responseOptions . containsLowercaseCharacter && {
53
- containsLowercaseLetter : responseOptions . containsLowercaseCharacter
54
- } ) ,
55
- ...( responseOptions . containsUppercaseCharacter && {
56
- containsUppercaseLetter : responseOptions . containsUppercaseCharacter
57
- } ) ,
58
- ...( responseOptions . containsNumericCharacter && {
59
- containsNumericCharacter : responseOptions . containsNumericCharacter
60
- } ) ,
61
- ...( responseOptions . containsNonAlphanumericCharacter && {
62
- containsNonAlphanumericCharacter :
63
- responseOptions . containsNonAlphanumericCharacter
64
- } )
65
- } ;
39
+ this . customStrengthOptions = { } ;
40
+ if ( responseOptions . minPasswordLength ) {
41
+ this . customStrengthOptions . minPasswordLength =
42
+ responseOptions . minPasswordLength ;
43
+ }
44
+ if ( responseOptions . maxPasswordLength ) {
45
+ this . customStrengthOptions . maxPasswordLength =
46
+ responseOptions . maxPasswordLength ;
47
+ }
48
+ if ( responseOptions . containsLowercaseCharacter ) {
49
+ this . customStrengthOptions . containsLowercaseLetter =
50
+ responseOptions . containsLowercaseCharacter ;
51
+ }
52
+ if ( responseOptions . containsUppercaseCharacter ) {
53
+ this . customStrengthOptions . containsUppercaseLetter =
54
+ responseOptions . containsUppercaseCharacter ;
55
+ }
56
+ if ( responseOptions . containsNumericCharacter ) {
57
+ this . customStrengthOptions . containsNumericCharacter =
58
+ responseOptions . containsNumericCharacter ;
59
+ }
60
+ if ( responseOptions . containsNonAlphanumericCharacter ) {
61
+ this . customStrengthOptions . containsNonAlphanumericCharacter =
62
+ responseOptions . containsNonAlphanumericCharacter ;
63
+ }
66
64
67
65
if ( response . allowedNonAlphanumericCharacters ) {
68
66
this . allowedNonAlphanumericCharacters =
0 commit comments