@@ -226,43 +226,6 @@ def get_by_session_token(
226226 )
227227 )
228228
229- @provide_global_contextual_session
230- def get_or_add_by_phone_number_and_client_id (
231- self ,
232- session ,
233- client_id ,
234- phone_number ,
235- user_type = EntityType .FORTMATIC .value ,
236- ):
237- if phone_number is None :
238- raise MissingPhoneNumber ()
239-
240- row = self .get_by_phone_number_and_client_id (
241- session = session ,
242- phone_number = phone_number ,
243- client_id = client_id ,
244- user_type = user_type ,
245- )
246-
247- if row :
248- return row
249-
250- row = self ._repository .add (
251- session = session ,
252- phone_number = phone_number ,
253- client_id = client_id ,
254- user_type = user_type ,
255- provenance = Provenance .SMS ,
256- )
257- logger .info (
258- "New auth user (id: {}) created by phone number (client_id: {})" .format (
259- row .id ,
260- client_id ,
261- ),
262- )
263-
264- return row
265-
266229 @provide_global_contextual_session
267230 def get_by_active_identifier_and_client_id (
268231 self ,
@@ -319,25 +282,6 @@ def get_by_email_and_client_id(
319282 for_update = for_update ,
320283 )
321284
322- @provide_global_contextual_session
323- def get_by_phone_number_and_client_id (
324- self ,
325- session ,
326- phone_number ,
327- client_id ,
328- user_type = EntityType .FORTMATIC .value ,
329- ):
330- if phone_number is None :
331- raise MissingPhoneNumber ()
332-
333- return self .get_by_active_identifier_and_client_id (
334- session = session ,
335- identifier_field = auth_user_model .phone_number ,
336- identifier_value = phone_number ,
337- client_id = client_id ,
338- user_type = user_type ,
339- )
340-
341285 @provide_global_contextual_session
342286 def exist_by_email_and_client_id (
343287 self ,
@@ -392,17 +336,6 @@ def get_user_count_by_client_id_and_user_type(self, session, client_id, user_typ
392336
393337 return session .execute (query ).scalar ()
394338
395- @provide_global_contextual_session
396- def get_by_client_id_and_global_auth_user (self , session , client_id , global_auth_user_id ):
397- return self ._repository .get_by (
398- session = session ,
399- filters = [
400- auth_user_model .client_id == client_id ,
401- auth_user_model .user_type == EntityType .CONNECT .value ,
402- auth_user_model .global_auth_user_id == global_auth_user_id ,
403- ],
404- )
405-
406339 @provide_global_contextual_session
407340 def get_by_client_id_and_user_type (
408341 self ,
@@ -420,61 +353,6 @@ def get_by_client_id_and_user_type(
420353 limit = limit ,
421354 )
422355
423- @provide_global_contextual_session
424- def get_by_client_ids_and_user_type (
425- self ,
426- session ,
427- client_ids ,
428- user_type ,
429- offset = None ,
430- limit = None ,
431- ):
432- if not client_ids :
433- return []
434-
435- return self ._repository .get_by (
436- session ,
437- filters = [
438- auth_user_model .client_id .in_ (client_ids ),
439- auth_user_model .user_type == user_type ,
440- auth_user_model .date_verified != None ,
441- ],
442- offset = offset ,
443- limit = limit ,
444- order_by_clause = auth_user_model .id .desc (),
445- )
446-
447- @provide_global_contextual_session
448- def get_by_client_id_with_substring_search (
449- self ,
450- session ,
451- client_id ,
452- substring ,
453- offset = None ,
454- limit = 10 ,
455- join_list = None ,
456- ):
457- return self ._repository .get_by (
458- session ,
459- filters = [
460- auth_user_model .client_id == client_id ,
461- auth_user_model .user_type == EntityType .MAGIC .value ,
462- sa .or_ (
463- auth_user_model .provenance == Provenance .SMS ,
464- auth_user_model .provenance == Provenance .LINK ,
465- auth_user_model .provenance == None , # noqa: E711
466- ),
467- sa .or_ (
468- auth_user_model .phone_number .contains (substring ),
469- auth_user_model .email .contains (substring ),
470- ),
471- ],
472- offset = offset ,
473- limit = limit ,
474- order_by_clause = auth_user_model .id .desc (),
475- join_list = join_list ,
476- )
477-
478356 @provide_global_contextual_session
479357 def yield_by_chunk (self , session , chunk_size , filters = None , join_list = None ):
480358 yield from self ._repository .yield_by_chunk (
@@ -518,72 +396,6 @@ def get_by_email(
518396 join_list = join_list ,
519397 )
520398
521- @provide_global_contextual_session
522- def get_by_email_for_interop (
523- self ,
524- session ,
525- email : str ,
526- wallet_type : WalletType ,
527- network : str ,
528- ) -> t .List [auth_user_model ]:
529- """
530- Custom method for searching for users eligible for interop. Unfortunately, this can't be done with the current
531- abstractions in our sql_repository, so this is a one-off bespoke method.
532- If we need to add more similar queries involving eager loading and multiple joins, we can add an abstraction
533- inside the repository.
534- """
535-
536- query = (
537- session .query (auth_user_model )
538- .join (
539- auth_user_model .wallets .and_ (
540- auth_wallet_model .wallet_type == str (wallet_type )
541- ).and_ (auth_wallet_model .network == network )
542- )
543- .options (sa .orm .contains_eager (auth_user_model .wallets ))
544- .join (
545- auth_user_model .magic_client .and_ (
546- magic_client_model .connect_interop == ConnectInteropStatus .ENABLED ,
547- ),
548- )
549- .options (sa .orm .contains_eager (auth_user_model .magic_client ))
550- .filter (
551- auth_wallet_model .wallet_type == wallet_type ,
552- auth_wallet_model .network == network ,
553- )
554- .filter (
555- auth_user_model .email == email ,
556- auth_user_model .user_type == EntityType .MAGIC .value ,
557- )
558- .populate_existing ()
559- )
560-
561- return query .all ()
562-
563- @provide_global_contextual_session
564- def get_linked_users (self , session , primary_auth_user_id , join_list , no_op = False ):
565- # TODO(magic-ravi#67899|2022-12-30): Re-enable account linked users for interop. Remove no_op flag.
566- if no_op :
567- return []
568- else :
569- return self ._repository .get_by (
570- session ,
571- filters = [
572- auth_user_model .user_type == EntityType .MAGIC .value ,
573- auth_user_model .linked_primary_auth_user_id == primary_auth_user_id ,
574- ],
575- join_list = join_list ,
576- )
577-
578- @provide_global_contextual_session
579- def get_by_phone_number (self , session , phone_number ):
580- return self ._repository .get_by (
581- session ,
582- filters = [
583- auth_user_model .phone_number == phone_number ,
584- ],
585- )
586-
587399
588400class AuthWallet (LogicComponent [auth_wallet_model , ObjectID , sa .orm .Session ]):
589401 model = auth_wallet_model
0 commit comments