Skip to content

Commit a7ee64f

Browse files
committed
CRITICAL FIX: Simplify password validation for existing passwords
- Mopar.com password requirements vary and have changed over time - Existing working passwords may not meet current new password requirements - Simplified validation to only check: length >= 8, length <= 20 - Removed strict requirements: uppercase, lowercase, number, special char, no repeats, no sequential - User's working password was being rejected on startup - All 25 config validator tests passing
1 parent b150b31 commit a7ee64f

2 files changed

Lines changed: 40 additions & 150 deletions

File tree

src/config-validator.js

Lines changed: 10 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -19,45 +19,21 @@ class ConfigValidator {
1919
errors.push('Email format is invalid (must be a valid email address)');
2020
}
2121

22-
// Password validation (based on Mopar.com requirements)
22+
// Password validation - only basic checks
23+
// Mopar.com requirements vary and existing passwords should work
2324
if (!config.password) {
2425
errors.push('Password is required');
2526
} else {
2627
const password = config.password;
27-
28-
// Length: 8-16 characters
29-
if (password.length < 8 || password.length > 16) {
30-
errors.push('Password must be 8-16 characters (Mopar requirement)');
31-
}
32-
33-
// Must have uppercase
34-
if (!/[A-Z]/.test(password)) {
35-
errors.push('Password must contain at least 1 uppercase letter (A-Z)');
36-
}
37-
38-
// Must have lowercase
39-
if (!/[a-z]/.test(password)) {
40-
errors.push('Password must contain at least 1 lowercase letter (a-z)');
41-
}
42-
43-
// Must have number
44-
if (!/[0-9]/.test(password)) {
45-
errors.push('Password must contain at least 1 number (0-9)');
46-
}
47-
48-
// Must have special character from allowed set
49-
if (!/[@$!%*?&_-]/.test(password)) {
50-
errors.push('Password must contain at least 1 special character (@$!%*?&_-)');
51-
}
52-
53-
// No character repeated more than twice
54-
if (/(.)\1{2,}/.test(password)) {
55-
errors.push('Password cannot have any character repeated more than twice (e.g. aaa, 111)');
28+
29+
// Only validate minimum length - existing passwords may not meet current Mopar requirements
30+
if (password.length < 8) {
31+
errors.push('Password must be at least 8 characters');
5632
}
57-
58-
// No more than two sequential characters
59-
if (this.hasSequentialCharacters(password)) {
60-
errors.push('Password cannot have more than two sequential characters (e.g. ABC, xyz, 123)');
33+
34+
// Warn if password seems too long (Mopar used to have 16 char limit)
35+
if (password.length > 20) {
36+
errors.push('Password seems unusually long (may not work with Mopar.com)');
6137
}
6238
}
6339

@@ -89,30 +65,6 @@ class ConfigValidator {
8965
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
9066
}
9167

92-
/**
93-
* Check if password has more than two sequential characters
94-
* Sequential means: ABC, xyz, 123, etc. (or reverse: CBA, zyx, 321)
95-
* @param {string} password - Password to check
96-
* @returns {boolean} True if has sequential characters
97-
*/
98-
static hasSequentialCharacters(password) {
99-
for (let i = 0; i < password.length - 2; i++) {
100-
const char1 = password.charCodeAt(i);
101-
const char2 = password.charCodeAt(i + 1);
102-
const char3 = password.charCodeAt(i + 2);
103-
104-
// Check if three consecutive characters are sequential
105-
// e.g., ABC (65,66,67), xyz (120,121,122), 123 (49,50,51)
106-
if (char2 === char1 + 1 && char3 === char2 + 1) {
107-
return true; // Found sequential ascending (ABC, xyz, 123)
108-
}
109-
if (char2 === char1 - 1 && char3 === char2 - 1) {
110-
return true; // Found sequential descending (CBA, zyx, 321)
111-
}
112-
}
113-
return false;
114-
}
115-
11668
/**
11769
* Log validation errors in a user-friendly format
11870
* @param {string[]} errors - Array of error messages

src/config-validator.test.js

Lines changed: 30 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -98,106 +98,46 @@ describe('ConfigValidator', () => {
9898
const result = ConfigValidator.validate(config);
9999

100100
expect(result.valid).toBe(false);
101-
expect(result.errors).toContain('Password must be 8-16 characters (Mopar requirement)');
101+
expect(result.errors).toContain('Password must be at least 8 characters');
102102
});
103103

104-
test('should fail when password is too long', () => {
104+
test('should fail when password is extremely long', () => {
105105
const config = {
106106
email: 'test@example.com',
107-
password: 'ThisPasswordIsTooLong17!',
107+
password: 'ThisPasswordIsWayTooLongForAnything1234567890',
108108
};
109109

110110
const result = ConfigValidator.validate(config);
111111

112112
expect(result.valid).toBe(false);
113-
expect(result.errors).toContain('Password must be 8-16 characters (Mopar requirement)');
113+
expect(result.errors).toContain('Password seems unusually long (may not work with Mopar.com)');
114114
});
115115

116-
test('should fail when password missing uppercase', () => {
116+
test('should pass with 8-character password', () => {
117117
const config = {
118118
email: 'test@example.com',
119-
password: 'password1!',
119+
password: 'password',
120120
};
121121

122122
const result = ConfigValidator.validate(config);
123123

124-
expect(result.valid).toBe(false);
125-
expect(result.errors).toContain('Password must contain at least 1 uppercase letter (A-Z)');
126-
});
127-
128-
test('should fail when password missing lowercase', () => {
129-
const config = {
130-
email: 'test@example.com',
131-
password: 'PASSWORD1!',
132-
};
133-
134-
const result = ConfigValidator.validate(config);
135-
136-
expect(result.valid).toBe(false);
137-
expect(result.errors).toContain('Password must contain at least 1 lowercase letter (a-z)');
138-
});
139-
140-
test('should fail when password missing number', () => {
141-
const config = {
142-
email: 'test@example.com',
143-
password: 'Password!',
144-
};
145-
146-
const result = ConfigValidator.validate(config);
147-
148-
expect(result.valid).toBe(false);
149-
expect(result.errors).toContain('Password must contain at least 1 number (0-9)');
150-
});
151-
152-
test('should fail when password missing special character', () => {
153-
const config = {
154-
email: 'test@example.com',
155-
password: 'Password1',
156-
};
157-
158-
const result = ConfigValidator.validate(config);
159-
160-
expect(result.valid).toBe(false);
161-
expect(result.errors).toContain('Password must contain at least 1 special character (@$!%*?&_-)');
162-
});
163-
164-
test('should fail when password has character repeated 3 times', () => {
165-
const config = {
166-
email: 'test@example.com',
167-
password: 'Passsword1!',
168-
};
169-
170-
const result = ConfigValidator.validate(config);
171-
172-
expect(result.valid).toBe(false);
173-
expect(result.errors).toContain('Password cannot have any character repeated more than twice (e.g. aaa, 111)');
174-
});
175-
176-
test('should fail when password has sequential ascending characters', () => {
177-
const config = {
178-
email: 'test@example.com',
179-
password: 'XYZword5!',
180-
};
181-
182-
const result = ConfigValidator.validate(config);
183-
184-
expect(result.valid).toBe(false);
185-
expect(result.errors).toContain('Password cannot have more than two sequential characters (e.g. ABC, xyz, 123)');
124+
expect(result.valid).toBe(true);
125+
expect(result.errors).toEqual([]);
186126
});
187127

188-
test('should fail when password has sequential numbers', () => {
128+
test('should pass with password without special characters', () => {
189129
const config = {
190130
email: 'test@example.com',
191-
password: 'Password123!',
131+
password: 'MyPassword15',
192132
};
193133

194134
const result = ConfigValidator.validate(config);
195135

196-
expect(result.valid).toBe(false);
197-
expect(result.errors).toContain('Password cannot have more than two sequential characters (e.g. ABC, xyz, 123)');
136+
expect(result.valid).toBe(true);
137+
expect(result.errors).toEqual([]);
198138
});
199139

200-
test('should pass with valid Mopar-compliant password', () => {
140+
test('should pass with password containing special characters', () => {
201141
const config = {
202142
email: 'test@example.com',
203143
password: 'MyPass42!',
@@ -209,16 +149,20 @@ describe('ConfigValidator', () => {
209149
expect(result.errors).toEqual([]);
210150
});
211151

212-
test('should pass with another valid password', () => {
213-
const config = {
214-
email: 'test@example.com',
215-
password: 'Secure$2024',
216-
};
217-
218-
const result = ConfigValidator.validate(config);
219-
220-
expect(result.valid).toBe(true);
221-
expect(result.errors).toEqual([]);
152+
test('should pass with various valid passwords', () => {
153+
const validPasswords = [
154+
'password123', // no special char, no uppercase
155+
'PASSWORD123', // no special char, no lowercase
156+
'Password', // no number, no special char
157+
'MyPass42!', // all requirements (if they existed)
158+
'Secure$2024', // all requirements
159+
];
160+
161+
validPasswords.forEach((password) => {
162+
const config = { email: 'test@example.com', password };
163+
const result = ConfigValidator.validate(config);
164+
expect(result.valid).toBe(true);
165+
});
222166
});
223167

224168
test('should fail when PIN is not 4 digits', () => {
@@ -320,16 +264,10 @@ describe('ConfigValidator', () => {
320264
const result = ConfigValidator.validate(config);
321265

322266
expect(result.valid).toBe(false);
323-
// Password "short" will fail multiple requirements:
324-
// 1. Email invalid
325-
// 2. Length (< 8)
326-
// 3. No uppercase
327-
// 4. No number
328-
// 5. No special char
329-
// 6. PIN invalid
330-
// 7. Debug not boolean
331-
expect(result.errors.length).toBeGreaterThanOrEqual(7);
267+
// Should have at least 4 errors: email, password, PIN, debug
268+
expect(result.errors.length).toBe(4);
332269
expect(result.errors).toContain('Email format is invalid (must be a valid email address)');
270+
expect(result.errors).toContain('Password must be at least 8 characters');
333271
expect(result.errors).toContain('PIN must be exactly 4 digits (e.g. "1234")');
334272
expect(result.errors).toContain('Debug mode must be true or false');
335273
});

0 commit comments

Comments
 (0)