1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//! # actix-web-admin
//!
//! A powerful admin panel library for Actix-web 4 with a pluggable authentication system.
//!
//! ## Quick Start
//!
//! ```rust,no_run
//! use actix_web::{web, App, HttpServer};
//! use actix_session::storage::CookieSessionStore;
//! use actix_session::SessionMiddleware;
//! use actix_web_admin::auth::{UserStore, JsonUserStore};
//! use actix_web_admin::{AdminRegistry, AdminSite, init_templates};
//! use std::sync::Arc;
//!
//! #[actix_web::main]
//! async fn main() -> std::io::Result<()> {
//! let templates = init_templates();
//!
//! let store = Arc::new(JsonUserStore::new("users.json"));
//! if store.find_by_username("admin").await.unwrap().is_none() {
//! store.create_user("admin", "admin@example.com", "Admin", "admin", true).await.unwrap();
//! }
//!
//! HttpServer::new(move || {
//! let mut registry = AdminRegistry::new();
//! // Register your resources...
//!
//! App::new()
//! .app_data(web::Data::new(templates.clone()))
//! .app_data(web::Data::new(store.clone() as Arc<dyn UserStore>))
//! .wrap(SessionMiddleware::new(CookieSessionStore::default(), actix_web::cookie::Key::generate()))
//! .configure(|cfg| {
//! AdminSite::new("/admin")
//! .with_user_store(store.clone())
//! .mount(cfg, registry)
//! })
//! })
//! .bind(("127.0.0.1", 8080))?
//! .run()
//! .await
//! }
//! ```
pub use AdminResource;
pub use AdminRegistry;
pub use AdminSite;
use Tera;
use Arc;
/// Helper to create a Tera instance with embedded templates.
pub type AdminTemplates = ;