From 774485957d831b930936296c00fa963288f17c73 Mon Sep 17 00:00:00 2001 From: Jonni Liljamo Date: Fri, 17 Mar 2023 13:51:58 +0200 Subject: [PATCH] fix(shared): update api calls to use cookies instead of tokens --- shared/src/api/game/all_forming.rs | 6 +++--- shared/src/api/game/create.rs | 8 ++++---- shared/src/api/game/mygames.rs | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/shared/src/api/game/all_forming.rs b/shared/src/api/game/all_forming.rs index eb9fc76..415e84f 100644 --- a/shared/src/api/game/all_forming.rs +++ b/shared/src/api/game/all_forming.rs @@ -6,7 +6,7 @@ * See LICENSE for licensing information. */ -use reqwest; +use reqwest::{self, header::COOKIE}; use serde::{Deserialize, Serialize}; use crate::{error::api::APIError, types::game::Game}; @@ -20,12 +20,12 @@ pub enum ResponseAllForming { Valid(ResultAllForming), } -pub fn all_forming(api_address: String, token: String) -> ResponseAllForming { +pub fn all_forming(api_address: String, cookie: &String) -> ResponseAllForming { let client = reqwest::blocking::Client::new(); let resp = client .get(&format!("{}/game/all_forming", api_address)) - .header("Authorization", token) + .header(COOKIE, &format!("id={}", cookie)) .send() .unwrap(); diff --git a/shared/src/api/game/create.rs b/shared/src/api/game/create.rs index 4542cdb..9cec1b6 100644 --- a/shared/src/api/game/create.rs +++ b/shared/src/api/game/create.rs @@ -6,7 +6,7 @@ * See LICENSE for licensing information. */ -use reqwest; +use reqwest::{self, header::COOKIE}; use serde::{Deserialize, Serialize}; use crate::{error::api::APIError, types::game::Game}; @@ -18,12 +18,12 @@ pub enum ResponseCreateGame { Valid(Game), } -pub fn create(api_address: String, token: String) -> ResponseCreateGame { +pub fn create(api_address: &String, cookie: &String) -> ResponseCreateGame { let client = reqwest::blocking::Client::new(); let resp = client - .post(&format!("{}/game/create", api_address)) - .header("Authorization", token) + .post(&format!("{}/game", api_address)) + .header(COOKIE, &format!("id={}", cookie)) .send() .unwrap(); diff --git a/shared/src/api/game/mygames.rs b/shared/src/api/game/mygames.rs index bcd0c5f..b890920 100644 --- a/shared/src/api/game/mygames.rs +++ b/shared/src/api/game/mygames.rs @@ -6,7 +6,7 @@ * See LICENSE for licensing information. */ -use reqwest; +use reqwest::{self, header::COOKIE}; use serde::{Deserialize, Serialize}; use crate::{error::api::APIError, types::game::Game}; @@ -20,12 +20,12 @@ pub enum ResponseMyGames { Valid(ResultMyGames), } -pub fn my_games(api_address: String, token: String) -> ResponseMyGames { +pub fn my_games(api_address: String, cookie: &String) -> ResponseMyGames { let client = reqwest::blocking::Client::new(); let resp = client .get(&format!("{}/game/my_games", api_address)) - .header("Authorization", token) + .header(COOKIE, &format!("id={}", cookie)) .send() .unwrap(); -- 2.44.1