works on adding from list
This commit is contained in:
@@ -1,13 +1,16 @@
|
||||
use actix_cors::Cors;
|
||||
use actix_files as fs;
|
||||
use actix_identity::{CookieIdentityPolicy, Identity, IdentityService, RequestIdentity};
|
||||
use actix_service::{Service, Transform};
|
||||
use actix_web::{
|
||||
dev::{ServiceRequest, ServiceResponse},
|
||||
http::{header, StatusCode},
|
||||
middleware, web, App, Error, HttpResponse, HttpServer,
|
||||
};
|
||||
use actix_service::{Service, Transform};
|
||||
use futures::{Future, future::{ok, Either, FutureResult}};
|
||||
use futures::{
|
||||
future::{ok, Either, FutureResult},
|
||||
Future,
|
||||
};
|
||||
use std::env;
|
||||
|
||||
use crate::api;
|
||||
@@ -46,7 +49,6 @@ fn restricted_to_group(id: i32, params: (AppPool, api::ApiActions)) -> MaybeForb
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct RestrictedAccess;
|
||||
|
||||
impl<S, B> Transform<S> for RestrictedAccess
|
||||
@@ -67,7 +69,7 @@ where
|
||||
}
|
||||
|
||||
struct RestrictedAccessMiddleware<S> {
|
||||
service: S
|
||||
service: S,
|
||||
}
|
||||
|
||||
impl<S, B> Service for RestrictedAccessMiddleware<S>
|
||||
@@ -90,9 +92,9 @@ where
|
||||
if is_logged_in {
|
||||
Either::A(self.service.call(req))
|
||||
} else {
|
||||
Either::B(ok(req.into_response(
|
||||
HttpResponse::Forbidden().finish().into_body()
|
||||
)))
|
||||
Either::B(ok(
|
||||
req.into_response(HttpResponse::Forbidden().finish().into_body())
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -186,9 +188,16 @@ fn configure_api(config: &mut web::ServiceConfig) {
|
||||
"/claims",
|
||||
web::get().to_async(|pool| db_call(pool, Q::FetchClaims)),
|
||||
)
|
||||
.route(
|
||||
"/items",
|
||||
web::get().to_async(move |pool: AppPool| db_call(pool, Q::FetchInventory)),
|
||||
.service(
|
||||
web::resource("/items")
|
||||
.route(
|
||||
web::get().to_async(move |pool: AppPool| db_call(pool, Q::FetchInventory)),
|
||||
)
|
||||
.route(web::post().to_async(
|
||||
move |pool: AppPool, items: web::Json<Vec<String>>| {
|
||||
db_call(pool, Q::CheckItemList(items.into_inner()))
|
||||
},
|
||||
)),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user