1#[macro_use]
2extern crate serde;
3#[macro_use]
4extern crate lazy_static;
5#[macro_use]
6extern crate async_trait;
7#[macro_use]
8extern crate nanoid;
9#[macro_use]
10extern crate log;
11#[macro_use]
12extern crate serde_json;
13
14#[cfg(feature = "schemas")]
15#[macro_use]
16extern crate schemars;
17#[cfg(feature = "database-mongodb")]
18#[macro_use]
19extern crate bson;
20
21mod result;
22pub use result::*;
23
24pub mod config;
25pub mod database;
26pub mod derive;
27pub mod events;
28pub mod r#impl;
29pub mod models;
30pub mod util;
31
32pub use config::Config;
33pub use database::{Database, Migration};
34pub use events::AuthifierEvent;
35
36use async_std::channel::Sender;
37
38#[derive(Default, Clone)]
40pub struct Authifier {
41 pub config: Config,
42 pub database: Database,
43 pub event_channel: Option<Sender<AuthifierEvent>>,
44}
45
46impl Authifier {
47 pub async fn publish_event(&self, event: AuthifierEvent) {
48 if let Some(sender) = &self.event_channel {
49 if let Err(err) = sender.send(event).await {
50 error!("Failed to publish an Authifier event: {:?}", err);
51 }
52 }
53 }
54}