@@ -18,6 +18,7 @@ pub struct SmsVerificationService {
1818 hasher_argon2id : HasherArgon2id ,
1919 max_verifications_per_week : u32 ,
2020 max_verifications_per_year : u32 ,
21+ limit_whitelist : Vec < String > ,
2122}
2223
2324impl SmsVerificationService {
@@ -26,22 +27,28 @@ impl SmsVerificationService {
2627 homeserver_admin_api : HomeserverAdminAPI ,
2728 max_verifications_per_week : u32 ,
2829 max_verifications_per_year : u32 ,
30+ limit_whitelist : Vec < String > ,
2931 ) -> Self {
3032 Self {
3133 prelude_api,
3234 homeserver_admin_api,
3335 hasher_argon2id : HasherArgon2id :: new ( ) ,
3436 max_verifications_per_week,
3537 max_verifications_per_year,
38+ limit_whitelist,
3639 }
3740 }
3841
3942 /// Check if a phone number has reached its limits for new verificaitons
4043 pub async fn check_verification_limit (
4144 & mut self ,
4245 executor : & mut UnifiedExecutor < ' _ > ,
46+ phone_number : & str ,
4347 phone_number_hash : & str ,
4448 ) -> Result < ( ) , SmsVerificationError > {
49+ if self . limit_whitelist . iter ( ) . any ( |w| w == phone_number) {
50+ return Ok ( ( ) ) ;
51+ }
4552 let weekly_count = SmsVerificationRepository :: count_verified_sessions_in_last_days (
4653 executor,
4754 phone_number_hash,
@@ -90,8 +97,12 @@ impl SmsVerificationService {
9097
9198 let mut executor: UnifiedExecutor < ' _ > = db. pool ( ) . into ( ) ;
9299
93- self . check_verification_limit ( & mut executor, & phone_number_hash)
94- . await ?;
100+ self . check_verification_limit (
101+ & mut executor,
102+ request. phone_number . as_str ( ) ,
103+ & phone_number_hash,
104+ )
105+ . await ?;
95106
96107 let prelude_response = self
97108 . prelude_api
0 commit comments