diff options
author | niliara-edu <nil.jimeno@estudiant.fjaverianas.com> | 2025-01-25 13:30:27 +0100 |
---|---|---|
committer | niliara-edu <nil.jimeno@estudiant.fjaverianas.com> | 2025-01-25 13:30:27 +0100 |
commit | ef604ccb6e86b77517a78547bb50cdf9b82e03f0 (patch) | |
tree | af490a61546a38ad1fbb40e43e985cc6ff82fd34 /src/api/artist.rs | |
parent | c2786c4b9d704128da80ce4ed6513b9f5507b680 (diff) |
add required authentication
Diffstat (limited to 'src/api/artist.rs')
-rw-r--r-- | src/api/artist.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/api/artist.rs b/src/api/artist.rs index 155f982..6cc0f35 100644 --- a/src/api/artist.rs +++ b/src/api/artist.rs @@ -1,5 +1,6 @@ use crate::api::{get_response_from_query, Response}; use crate::database::{Artist, ArtistPost, ArtistPut, Delete}; +use crate::extractors::auth_token::AuthenticationToken; use crate::AppState; use actix_web::{delete, get, post, put, web, HttpResponse}; use serde::Deserialize; @@ -50,6 +51,7 @@ pub async fn get_artist( pub async fn post_artist( app_state: web::Data<AppState>, request_data: web::Json<ArtistPost>, + _auth_token: AuthenticationToken, ) -> HttpResponse { get_response_from_query( app_state @@ -64,9 +66,13 @@ pub async fn post_artist( pub async fn put_artist( app_state: web::Data<AppState>, request_data: web::Json<ArtistPut>, + _auth_token: AuthenticationToken, ) -> HttpResponse { get_response_from_query( - app_state.database.edit_artist(request_data.into_inner()).await, + app_state + .database + .edit_artist(request_data.into_inner()) + .await, "PUT".to_string(), ) } @@ -75,6 +81,7 @@ pub async fn put_artist( pub async fn delete_artist( app_state: web::Data<AppState>, request_data: web::Json<Delete>, + _auth_token: AuthenticationToken, ) -> HttpResponse { /* Check if ID is valid (return -1 if invalid) */ let id: i32 = request_data |