Skip to content

Commit

Permalink
fix: add MCA email validation to auth options
Browse files Browse the repository at this point in the history
  • Loading branch information
joywin2003 committed Nov 24, 2024
1 parent 4b029c1 commit 8dc2b9b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/lib/auth-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const authOptions: NextAuthOptions = {
// Define BE and MBA patterns
const isBEEmail = /^[2][1-4]\d{3}\..+$/; // Matches 21XXXX, 22XXXX, 23XXXX, 24XXXX for BE
const isMBAEmail = /^[2][3-4]ba\d{3}\..+$/; // Matches 23baXXX, 24baXXX for MBA
const isMCAEmail = /^[2][3-4]ca\d{3}\..+$/; // Matches 23maXXX, 24maXXX for MCA

// Check BE email validity
if (isBEEmail.test(emailPrefix)) {
Expand All @@ -56,6 +57,11 @@ export const authOptions: NextAuthOptions = {
if (isMBAEmail.test(emailPrefix)) {
return true; // Allow MBA students with valid years
}

// Check MCA email validity
if (isMCAEmail.test(emailPrefix)) {
return true; // Allow MCA students with valid years
}

// If the email is sjec but does not fit the BE/MBA patterns, check the database
const isAllowed = await isAllowedToAccess(profile.email);
Expand Down

0 comments on commit 8dc2b9b

Please sign in to comment.