cyaxon_authifier/database/
definition.rs1use crate::{
2 models::{Account, Invite, MFATicket, Session},
3 Result, Success,
4};
5
6use super::Migration;
7
8#[async_trait]
9pub trait AbstractDatabase: std::marker::Sync {
10 async fn run_migration(&self, migration: Migration) -> Success;
12
13 async fn find_account(&self, id: &str) -> Result<Account>;
15
16 async fn find_account_by_normalized_email(
18 &self,
19 normalized_email: &str,
20 ) -> Result<Option<Account>>;
21
22 async fn find_account_with_email_verification(&self, token: &str) -> Result<Account>;
24
25 async fn find_account_with_password_reset(&self, token: &str) -> Result<Account>;
27
28 async fn find_account_with_deletion_token(&self, token: &str) -> Result<Account>;
30
31 async fn find_invite(&self, id: &str) -> Result<Invite>;
33
34 async fn find_session(&self, id: &str) -> Result<Session>;
36
37 async fn find_sessions(&self, user_id: &str) -> Result<Vec<Session>>;
39
40 async fn find_sessions_with_subscription(&self, user_ids: &[String]) -> Result<Vec<Session>>;
42
43 async fn find_session_by_token(&self, token: &str) -> Result<Option<Session>>;
45
46 async fn find_ticket_by_token(&self, token: &str) -> Result<Option<MFATicket>>;
48
49 async fn save_account(&self, account: &Account) -> Success;
51
52 async fn save_session(&self, session: &Session) -> Success;
54
55 async fn save_invite(&self, invite: &Invite) -> Success;
57
58 async fn save_ticket(&self, ticket: &MFATicket) -> Success;
60
61 async fn delete_session(&self, id: &str) -> Success;
63
64 async fn delete_all_sessions(&self, user_id: &str, ignore: Option<String>) -> Success;
66
67 async fn delete_ticket(&self, id: &str) -> Success;
69}