@@ -4,15 +4,15 @@ use async_trait::async_trait;
44use serde:: { Serialize , de:: DeserializeOwned } ;
55
66use crate :: {
7- ErasedMethodAction ,
8- action:: MethodAction ,
7+ action:: { ErasedMethodAction , MethodAction } ,
98 error:: { SessionError , ShieldError } ,
109 provider:: Provider ,
1110} ;
1211
1312#[ async_trait]
1413pub trait Method : Send + Sync {
1514 type Provider : Provider ;
15+ type Connection ;
1616 type Session : DeserializeOwned + Serialize ;
1717
1818 fn id ( & self ) -> String ;
@@ -40,6 +40,12 @@ pub trait Method: Send + Sync {
4040 . into_iter ( )
4141 . find ( |provider| provider. id ( ) . as_deref ( ) == provider_id) )
4242 }
43+
44+ async fn user_connections (
45+ & self ,
46+ user : & str ,
47+ provider_id : Option < & str > ,
48+ ) -> Result < Vec < Self :: Connection > , ShieldError > ;
4349}
4450
4551#[ async_trait]
@@ -59,6 +65,12 @@ pub trait ErasedMethod: Send + Sync {
5965 provider_id : Option < & str > ,
6066 ) -> Result < Option < Box < dyn Any + Send + Sync > > , ShieldError > ;
6167
68+ async fn erased_user_connections (
69+ & self ,
70+ user_id : & str ,
71+ provider_id : Option < & str > ,
72+ ) -> Result < Vec < Box < dyn Any + Send + Sync > > , ShieldError > ;
73+
6274 fn erased_deserialize_session (
6375 & self ,
6476 value : Option < & str > ,
@@ -110,6 +122,18 @@ macro_rules! erased_method {
110122 } )
111123 }
112124
125+ async fn erased_user_connections(
126+ & self ,
127+ user_id: & str ,
128+ provider_id: Option <& str >,
129+ ) -> Result <Vec <Box <dyn std:: any:: Any + Send + Sync >>, $crate:: ShieldError > {
130+ Ok ( self . user_connections( user_id, provider_id)
131+ . await ?
132+ . into_iter( )
133+ . map( |connection| Box :: new( connection) as Box <dyn std:: any:: Any + Send + Sync >)
134+ . collect( ) )
135+ }
136+
113137 fn erased_deserialize_session(
114138 & self ,
115139 value: Option <& str >
0 commit comments