Pour tout problème contactez-nous par mail : support@froggit.fr | La FAQ :grey_question: | Rejoignez-nous sur le Chat :speech_balloon:

Skip to content
Snippets Groups Projects
Commit f9a90661 authored by Pierre Jarriges's avatar Pierre Jarriges
Browse files

crud articles

parent 5eba8a48
No related branches found
No related tags found
No related merge requests found
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
FORM: update/delete article FORM: update/delete article
</main> </main>
</body> </body>
<script src="/v/admin-panel/assets/script.js"></script> <script src="/v/admin-panel/assets/script.js"></script>
</html> </html>
\ No newline at end of file
...@@ -21,7 +21,7 @@ use app_state::AppState; ...@@ -21,7 +21,7 @@ use app_state::AppState;
use env::get_log_level; use env::get_log_level;
use env_logger::Env; use env_logger::Env;
use middleware::AuthenticatedAdminMiddleware; use middleware::AuthenticatedAdminMiddleware;
use service::admin_auth::admin_auth; use service::*;
use standard_static_files::{favicon, robots, sitemap}; use standard_static_files::{favicon, robots, sitemap};
use std::env::var as env_var; use std::env::var as env_var;
use tls::get_tls_config; use tls::get_tls_config;
...@@ -79,9 +79,15 @@ async fn main() -> std::io::Result<()> { ...@@ -79,9 +79,15 @@ async fn main() -> std::io::Result<()> {
}, },
]))) ])))
.wrap(NormalizePath::new(TrailingSlash::Trim)) .wrap(NormalizePath::new(TrailingSlash::Trim))
.service(admin_auth) // .app_data(JsonConfig::default().limit(1 << 25u8)) // Allow json payload to have size until ~32MB
// Allow json payload to have size until ~32MB /////////////////////////////////////////////////////////////////////////////////////////////////////////////
// .app_data(JsonConfig::default().limit(1 << 25u8)) // REST API /////////////////////////////////////////////////////////////////////////////////////////////////
.service(admin_authentication)
.service(post_article)
.service(update_article)
.service(delete_article)
.service(get_articles_by_category)
.service(get_article)
///////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////
// STANDARD FILES /////////////////////////////////////////////////////////////////////////////////////////// // STANDARD FILES ///////////////////////////////////////////////////////////////////////////////////////////
.service(resource("/favicon.ico").route(get().to(favicon))) .service(resource("/favicon.ico").route(get().to(favicon)))
......
mod administrator; mod administrator;
mod article;
pub use administrator::*; pub use administrator::*;
pub use article::*;
pub mod admin_auth; mod admin_auth;
mod articles;
pub use admin_auth::*;
pub use articles::*;
...@@ -9,7 +9,7 @@ use actix_web::{ ...@@ -9,7 +9,7 @@ use actix_web::{
/// If the authentication succeed, a cookie with an auth token is returned /// If the authentication succeed, a cookie with an auth token is returned
/// If not, 401 is returned and if an auth cookie is found it is deleted. /// If not, 401 is returned and if an auth cookie is found it is deleted.
#[post("/admin-auth")] #[post("/admin-auth")]
pub async fn admin_auth<'a>( pub async fn admin_authentication<'a>(
app_state: Data<AppState>, app_state: Data<AppState>,
auth_mw: Data<AuthenticatedAdminMiddleware<'a>>, auth_mw: Data<AuthenticatedAdminMiddleware<'a>>,
req: HttpRequest, req: HttpRequest,
...@@ -77,7 +77,7 @@ mod test_admin_auth { ...@@ -77,7 +77,7 @@ mod test_admin_auth {
.app_data(Data::new(AuthenticatedAdminMiddleware::new( .app_data(Data::new(AuthenticatedAdminMiddleware::new(
"kuadrado-admin-auth", "kuadrado-admin-auth",
))) )))
.service(admin_auth), .service(admin_authentication),
) )
.await; .await;
...@@ -103,7 +103,7 @@ mod test_admin_auth { ...@@ -103,7 +103,7 @@ mod test_admin_auth {
.app_data(Data::new(AuthenticatedAdminMiddleware::new( .app_data(Data::new(AuthenticatedAdminMiddleware::new(
"kuadrado-admin-auth", "kuadrado-admin-auth",
))) )))
.service(admin_auth), .service(admin_authentication),
) )
.await; .await;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment