Skip to content

Commit 9e0352c

Browse files
committed
fix: ensures case insensitive email matching between stored and entered email
1 parent 9fb7e29 commit 9e0352c

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/lib/airtable/airtable.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,15 +199,15 @@ export function createAirtableClient(apiKey: string, baseId: string) {
199199
}
200200

201201
/**
202-
* Check if email exists in Apprentices table
202+
* Check if email exists in Apprentices table (case-insensitive)
203203
* Note: filterByFormula requires field NAME "Learner email" - this would break if renamed in Airtable
204204
*/
205205
async function findApprenticeByEmail(email: string): Promise<boolean> {
206206
const apprenticesTable = base(TABLES.APPRENTICES);
207207

208208
const apprenticeRecords = await apprenticesTable
209209
.select({
210-
filterByFormula: `{Learner email} = "${email}"`,
210+
filterByFormula: `LOWER({Learner email}) = LOWER("${email}")`,
211211
maxRecords: 1,
212212
returnFieldsByFieldId: true,
213213
})
@@ -224,7 +224,7 @@ export function createAirtableClient(apiKey: string, baseId: string) {
224224

225225
const records = await apprenticesTable
226226
.select({
227-
filterByFormula: `{Learner email} = "${email}"`,
227+
filterByFormula: `LOWER({Learner email}) = LOWER("${email}")`,
228228
maxRecords: 1,
229229
returnFieldsByFieldId: true,
230230
})

0 commit comments

Comments
 (0)