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
use crate::api::rcos::meetings::authorization_for::{AuthorizationFor, UserMeetingAuthorization};
use crate::error::TelescopeError;
use crate::web::middlewares::authorization::Authorization;
use actix_web::web::ServiceConfig;
use uuid::Uuid;
mod create;
mod delete;
mod edit;
mod list;
mod view;
pub fn register(config: &mut ServiceConfig) {
list::register(config);
create::register(config);
edit::register(config);
delete::register(config);
config
.service(view::meeting);
}
fn make_meeting_auth_middleware<F: 'static + Fn(&UserMeetingAuthorization) -> bool>(
f: &'static F,
) -> Authorization {
Authorization::new(move |user_id: Uuid| {
Box::pin(async move {
let auth: UserMeetingAuthorization = AuthorizationFor::get(Some(user_id)).await?;
(f)(&auth).then(|| ()).ok_or(TelescopeError::Forbidden)
})
})
}