1use std::sync::Arc;
2
3use async_trait::async_trait;
4use shield::{Method, MethodAction, ShieldError, Storage, User, erased_method};
5
6use crate::{actions::DummySignInAction, provider::DummyProvider};
7
8pub const DUMMY_METHOD_ID: &str = "dummy";
9
10pub struct DummyMethod<U: User> {
11 storage: Arc<dyn Storage<U>>,
12}
13
14impl<U: User> DummyMethod<U> {
15 pub fn new<S: Storage<U> + 'static>(storage: S) -> Self {
16 Self {
17 storage: Arc::new(storage),
18 }
19 }
20}
21
22#[async_trait]
23impl<U: User + 'static> Method for DummyMethod<U> {
24 type Provider = DummyProvider;
25 type Connection = ();
26 type Session = ();
27
28 fn id(&self) -> String {
29 DUMMY_METHOD_ID.to_owned()
30 }
31
32 fn actions(&self) -> Vec<Box<dyn MethodAction<Self::Provider, Self::Session>>> {
33 vec![Box::new(DummySignInAction::new(self.storage.clone()))]
34 }
35
36 async fn providers(&self) -> Result<Vec<Self::Provider>, ShieldError> {
37 Ok(vec![DummyProvider])
38 }
39
40 async fn user_connections(
41 &self,
42 _user_id: &str,
43 _provider_id: Option<&str>,
44 ) -> Result<Vec<Self::Connection>, ShieldError> {
45 Ok(vec![])
46 }
47}
48
49erased_method!(DummyMethod, <U: User>);