1
0

rm password

This commit is contained in:
syui 2024-02-18 23:38:33 +09:00
parent 83c234e8af
commit 3a19a207f3
Signed by: syui
GPG Key ID: 5417CFEBAD92DF56
2 changed files with 5 additions and 11 deletions

View File

@ -84,7 +84,6 @@ pub struct Token {
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub struct Data { pub struct Data {
pub host: String, pub host: String,
pub password: String,
pub did: String, pub did: String,
pub handle: String, pub handle: String,
pub access: String, pub access: String,
@ -130,7 +129,6 @@ pub fn url(s: &str) -> String {
let data = Data::new().unwrap(); let data = Data::new().unwrap();
let data = Data { let data = Data {
host: data.host, host: data.host,
password: data.password,
handle: data.handle, handle: data.handle,
did: data.did, did: data.did,
access: data.access, access: data.access,
@ -196,7 +194,6 @@ pub fn data_toml(s: &str) -> String {
let data = Data::new().unwrap(); let data = Data::new().unwrap();
let data = Data { let data = Data {
host: data.host, host: data.host,
password: data.password,
handle: data.handle, handle: data.handle,
did: data.did, did: data.did,
access: data.access, access: data.access,
@ -204,7 +201,6 @@ pub fn data_toml(s: &str) -> String {
}; };
match &*s { match &*s {
"host" => data.handle, "host" => data.handle,
"password" => data.password,
"handle" => data.handle, "handle" => data.handle,
"did" => data.did, "did" => data.did,
"access" => data.access, "access" => data.access,
@ -230,7 +226,6 @@ pub fn data_refresh(s: &str) -> String {
let data = Data::new().unwrap(); let data = Data::new().unwrap();
let data = Data { let data = Data {
host: data.host, host: data.host,
password: data.password,
handle: data.handle, handle: data.handle,
did: data.did, did: data.did,
access: data.access, access: data.access,
@ -240,7 +235,7 @@ pub fn data_refresh(s: &str) -> String {
let mut _file = match Refresh::new() let mut _file = match Refresh::new()
{ {
Err(_why) => c_refresh(&data.access, &data.refresh), Err(_why) => c_refresh(&data.access, &data.refresh),
Ok(_) => println!("ok"), Ok(_) => println!(""),
}; };
let refresh = Refresh::new().unwrap(); let refresh = Refresh::new().unwrap();
let refresh = Refresh { let refresh = Refresh {
@ -521,7 +516,7 @@ pub fn c_char(i: String) -> String {
return s; return s;
} }
pub fn w_cfg(h: &str, res: &str, password: &str) { pub fn w_cfg(h: &str, res: &str) {
let f = data_file(&"json"); let f = data_file(&"json");
let ff = data_file(&"toml"); let ff = data_file(&"toml");
let mut f = fs::File::create(f.clone()).unwrap(); let mut f = fs::File::create(f.clone()).unwrap();
@ -530,7 +525,6 @@ pub fn w_cfg(h: &str, res: &str, password: &str) {
let json: Token = serde_json::from_str(&res).unwrap(); let json: Token = serde_json::from_str(&res).unwrap();
let datas = Data { let datas = Data {
host: h.to_string(), host: h.to_string(),
password: password.to_string(),
did: json.did.to_string(), did: json.did.to_string(),
handle: json.handle.to_string(), handle: json.handle.to_string(),
access: json.accessJwt.to_string(), access: json.accessJwt.to_string(),

View File

@ -282,13 +282,13 @@ fn token(c: &Context) {
if let Ok(p) = c.string_flag("password") { if let Ok(p) = c.string_flag("password") {
if let Ok(s) = c.string_flag("server") { if let Ok(s) = c.string_flag("server") {
let res = token::post_request(m.to_string(), p.to_string(), s.to_string()).await; let res = token::post_request(m.to_string(), p.to_string(), s.to_string()).await;
w_cfg(&s, &res, &p); w_cfg(&s, &res);
w_refresh(&res); w_refresh(&res);
} else { } else {
let res = let res =
token::post_request(m.to_string(), p.to_string(), "bsky.social".to_string()) token::post_request(m.to_string(), p.to_string(), "bsky.social".to_string())
.await; .await;
w_cfg(&"bsky.social", &res, &p); w_cfg(&"bsky.social", &res);
w_refresh(&res); w_refresh(&res);
} }
} }