Changed auth_user_with_token to only accept an object

This commit is contained in:
Franklin 2022-08-27 16:20:34 -04:00
parent 44a0c92699
commit 671a448fd7
2 changed files with 4 additions and 3 deletions

2
Cargo.lock generated
View File

@ -99,7 +99,7 @@ dependencies = [
[[package]]
name = "dev-dtos"
version = "0.1.0"
source = "git+https://backend:Eo1n1TPsyWV7wwo9uFwgUJGKKheMM6paM2mDkVPA4zqkh5dt6Q6XPkbtojzYQudQsM84vSwKmhHHTPjyn535d6NLBmA3meeGj0Gb8if4sceAwvySdmzedg5mN2P5zzQt@gitea.blancoinfante.com/blancoinfante_backend/dev-dtos-rust.git#d8e899e4f208be54d1e7f93a2948de55309e88f3"
source = "git+https://backend:Eo1n1TPsyWV7wwo9uFwgUJGKKheMM6paM2mDkVPA4zqkh5dt6Q6XPkbtojzYQudQsM84vSwKmhHHTPjyn535d6NLBmA3meeGj0Gb8if4sceAwvySdmzedg5mN2P5zzQt@gitea.blancoinfante.com/blancoinfante_backend/dev-dtos-rust.git#8c59fdee30acd9f7dbaafd28660e47f2d275eb61"
dependencies = [
"chrono",
"serde",

View File

@ -6,8 +6,9 @@ use crate::middleware::client::perform_request;
//TODO: Move this into a separate service
const BASE_URL_USER_SVC: &str = "http://backend.blancoinfante.com";
pub async fn authenticate_user_with_token(client: &Client, user: &UserForAuthenticationDto, user_id: &i32) -> Result<User, Error> {
perform_request::<&UserForAuthenticationDto, User>(BASE_URL_USER_SVC.to_string(), client, Method::POST, format!("/user/auth/token/{}", user_id), Some(user), 200, vec![(String::from("auth-token"), user.token.clone())]).await
pub async fn authenticate_user_with_token(client: &Client, user: &UserForAuthenticationDto) -> Result<User, Error> {
//TODO: Remove the need for a userdto, just get token and Id, dont send the body
perform_request::<&UserForAuthenticationDto, User>(BASE_URL_USER_SVC.to_string(), client, Method::POST, format!("/user/auth/token/{}", user.id), None, 200, vec![(String::from("auth-token"), user.token.clone())]).await
}
pub async fn create_user(client: &Client, user: &UserForCreationDto) -> Result<Token, Error> {
perform_request::<&UserForCreationDto, Token>(BASE_URL_USER_SVC.to_string(), client, Method::POST, "/user".to_string(), Some(user), 200, vec![]).await