Skip to content

Commit 02de8ca

Browse files
lawrencehookclaude
andcommitted
Change grandfathered file from JSON to plain text (one email per line)
Co-Authored-By: Claude Opus 4.6 <[email protected]>
1 parent 3e8300c commit 02de8ca

4 files changed

Lines changed: 6 additions & 11 deletions

File tree

server/src/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@ module.exports = {
3333
get DATA_DIR() { return process.env.DATA_DIR || './data'; },
3434
AUTH_REQUESTS_DIR: 'auth-requests',
3535
RATE_LIMITS_DIR: 'rate-limits',
36-
GRANDFATHERED_FILE: 'grandfathered.json',
36+
GRANDFATHERED_FILE: 'grandfathered.txt',
3737
};

server/src/storage/index.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,8 @@ function readGrandfatheredEmails() {
3434
try {
3535
const filePath = path.join(getDataDir(), config.GRANDFATHERED_FILE);
3636
if (fs.existsSync(filePath)) {
37-
const data = JSON.parse(fs.readFileSync(filePath, 'utf8'));
38-
if (Array.isArray(data)) {
39-
return new Set(data.filter(e => typeof e === 'string').map(e => e.toLowerCase()));
40-
}
37+
const lines = fs.readFileSync(filePath, 'utf8').split('\n');
38+
return new Set(lines.map(l => l.trim().toLowerCase()).filter(l => l && !l.startsWith('#')));
4139
}
4240
} catch (err) {
4341
console.error('Failed to read grandfathered emails:', err.message);

server/tests/license.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ describe('License Routes', () => {
9595
it('should return license token with premium and grandfathered for grandfathered user', async () => {
9696
// Set up grandfathered file
9797
const grandfatheredFile = path.join(testDataDir, config.GRANDFATHERED_FILE);
98-
fs.writeFileSync(grandfatheredFile, JSON.stringify(['[email protected]']));
98+
fs.writeFileSync(grandfatheredFile, '[email protected]\n');
9999

100100

101101
const token = generateSessionToken('[email protected]');
@@ -115,7 +115,7 @@ describe('License Routes', () => {
115115

116116
it('should handle grandfathered check case-insensitively', async () => {
117117
const grandfatheredFile = path.join(testDataDir, config.GRANDFATHERED_FILE);
118-
fs.writeFileSync(grandfatheredFile, JSON.stringify(['[email protected]']));
118+
fs.writeFileSync(grandfatheredFile, '[email protected]\n');
119119

120120

121121
// Token with lowercase email

server/tests/storage.test.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,7 @@ describe('Storage', () => {
133133
describe('Grandfathered Emails', () => {
134134
it('should read grandfathered emails from file', () => {
135135
const grandfatheredFile = path.join(testDataDir, config.GRANDFATHERED_FILE);
136-
fs.writeFileSync(grandfatheredFile, JSON.stringify([
137-
138-
'[email protected]', // Test case insensitivity
139-
]));
136+
fs.writeFileSync(grandfatheredFile, '[email protected]\[email protected]\n');
140137

141138
assert.strictEqual(storage.isGrandfathered('[email protected]'), true);
142139
assert.strictEqual(storage.isGrandfathered('[email protected]'), true);

0 commit comments

Comments
 (0)