File tree Expand file tree Collapse file tree 2 files changed +23
-19
lines changed Expand file tree Collapse file tree 2 files changed +23
-19
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,23 @@ class Settings(BaseSettings):
2121 cors_allowed_origins : str
2222 # AAI Portal URL for admin links in emails
2323 aai_portal_url : str = "https://aaiportal.test.biocommons.org.au"
24+ # Allowed email domains for SBP registration
25+ sbp_allowed_email_domains : list [str ] = [
26+ # UNSW
27+ "@unsw.edu.au" , "@ad.unsw.edu.au" , "@student.unsw.edu.au" ,
28+ # BioCommons
29+ "@biocommons.org.au" ,
30+ # USyd
31+ "@sydney.edu.au" , "@uni.sydney.edu.au" ,
32+ # WEHI
33+ "@wehi.edu.au" ,
34+ # Monash
35+ "@monash.edu" , "@student.monash.edu" ,
36+ # Griffith
37+ "@griffith.edu.au" , "@griffithuni.edu.au" ,
38+ # UoM
39+ "@unimelb.edu.au" , "@student.unimelb.edu.au"
40+ ]
2441
2542 model_config = SettingsConfigDict (env_file = ".env" , extra = "ignore" )
2643
Original file line number Diff line number Diff line change 2424 route_class = RegistrationRoute
2525)
2626
27- # Allowed email domains for SBP registration
28- SBP_ALLOWED_EMAIL_DOMAINS = {
29- # UNSW
30- "@unsw.edu.au" , "@ad.unsw.edu.au" , "@student.unsw.edu.au" ,
31- # BioCommons
32- "@biocommons.org.au" ,
33- # USyd
34- "@sydney.edu.au" , "@uni.sydney.edu.au" ,
35- # WEHI
36- "@wehi.edu.au" ,
37- # Monash
38- "@monash.edu" , "@student.monash.edu" ,
39- # Griffith
40- "@griffith.edu.au" , "@griffithuni.edu.au" ,
41- # UoM
42- "@unimelb.edu.au" , "@student.unimelb.edu.au"
43- }
27+ def _validate_email_domain_with_list (email : str , allowed_domains : list [str ]) -> bool :
28+ email_lower = email .lower ()
29+ return any (email_lower .endswith (domain ) for domain in allowed_domains )
4430
4531
4632def validate_sbp_email_domain (email : str ) -> bool :
47- email_lower = email .lower ()
48- return any (email_lower .endswith (domain ) for domain in SBP_ALLOWED_EMAIL_DOMAINS )
33+ from config import get_settings
34+ settings = get_settings ()
35+ return _validate_email_domain_with_list (email , settings .sbp_allowed_email_domains )
4936
5037
5138def send_approval_email (registration : SBPRegistrationRequest , settings : Settings ):
You can’t perform that action at this time.
0 commit comments