diff options
author | metamuffin <metamuffin@disroot.org> | 2023-08-01 20:32:35 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2023-08-01 20:32:35 +0200 |
commit | ff9060ea0987e29e4d468ff7c9fed7cc7109bf2b (patch) | |
tree | fc8c7ad11ca2dfc7ebccb65ea9ea3c27827405dd /server/src/routes/api | |
parent | f7992589cf45c699599a7ee5fc4634c9db16ff87 (diff) | |
download | jellything-ff9060ea0987e29e4d468ff7c9fed7cc7109bf2b.tar jellything-ff9060ea0987e29e4d468ff7c9fed7cc7109bf2b.tar.bz2 jellything-ff9060ea0987e29e4d468ff7c9fed7cc7109bf2b.tar.zst |
federation possible but inconvinient
Diffstat (limited to 'server/src/routes/api')
-rw-r--r-- | server/src/routes/api/mod.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/server/src/routes/api/mod.rs b/server/src/routes/api/mod.rs index b39950c..84dd6a8 100644 --- a/server/src/routes/api/mod.rs +++ b/server/src/routes/api/mod.rs @@ -9,6 +9,7 @@ use super::ui::{ error::MyResult, }; use crate::database::Database; +use reqwest::Client; use rocket::{get, post, response::Redirect, serde::json::Json, State}; use serde_json::{json, Value}; @@ -27,3 +28,26 @@ pub fn r_api_account_login(database: &State<Database>, data: Json<LoginForm>) -> let token = login_logic(database, &data.username, &data.password)?; Ok(json!(token)) } +pub async fn c_api_account_login( + host: &str, + tls: bool, + username: String, + password: String, + expire: u64, +) -> MyResult<String> { + Ok(Client::builder() + .build()? + .post(format!( + "{}://{host}/api/account/login", + if tls { "https" } else { "http" } + )) + .body(serde_json::to_string(&LoginForm { + expire, + password, + username, + })?) + .send() + .await? + .json() + .await?) +} |