@@ -479,38 +479,27 @@ export class DataStoreService {
479479 }
480480
481481 /**
482- * Returns a promise resolving to true if the user's email is either
483- * explicitly listed as a document ID in the ' passlist' collection or
484- * matches the regular expression stored in the ' passlist/regexp' document .
482+ * Returns a promise resolving to true if the user's email is granted access
483+ * by the passlist: either an exact-email entry (` passlist/<email>`) or a
484+ * domain-wide entry (` passlist/@<domain>`) .
485485 *
486486 * @param userEmail The email of the user to check against the passlist.
487487 */
488488 async isPasslisted ( userEmail : string ) : Promise < boolean > {
489- const docSnapshot = await runInInjectionContext ( this . injector , ( ) =>
489+ const emailSnapshot = await runInInjectionContext ( this . injector , ( ) =>
490490 getDoc ( doc ( this . db , 'passlist' , userEmail ) )
491491 ) ;
492492
493- if ( docSnapshot . exists ( ) ) return true ;
493+ if ( emailSnapshot . exists ( ) ) return true ;
494494
495- const regexpSnapshot = await runInInjectionContext ( this . injector , ( ) =>
496- getDoc ( doc ( this . db , 'passlist' , 'regexp' ) )
497- ) ;
498-
499- if ( regexpSnapshot . exists ( ) ) {
500- const regexpData = regexpSnapshot . data ( ) as
501- | { regexp ?: string }
502- | undefined ;
503-
504- const regexpString = regexpData ?. regexp ;
505-
506- if ( regexpString ) {
507- const regex = new RegExp ( regexpString ) ;
495+ const domain = userEmail . split ( '@' ) [ 1 ] ;
496+ if ( ! domain ) return false ;
508497
509- return regex . test ( userEmail ) ;
510- }
511- }
498+ const domainSnapshot = await runInInjectionContext ( this . injector , ( ) =>
499+ getDoc ( doc ( this . db , 'passlist' , `@ ${ domain } ` ) )
500+ ) ;
512501
513- return false ;
502+ return domainSnapshot . exists ( ) ;
514503 }
515504
516505 private toLocationsOfInterest (
0 commit comments