fixed config dir problem

This commit is contained in:
Zastian Pretorius
2022-10-26 22:15:05 +01:00
parent 1e02417c15
commit e9de97e4da

View File

@@ -13,18 +13,15 @@ pub fn get_token() -> String {
if !token_path.exists() { if !token_path.exists() {
//create empty file //create empty file
fs::File::create(&token_path).unwrap(); fs::File::create(&token_path).unwrap();
} else { }
//read token from file //read token from file
let token = fs::read_to_string(&token_path).unwrap(); let token = fs::read_to_string(&token_path).unwrap();
if token.is_empty() { if token.is_empty() {
println!("please go to the below link and copy and past the token below"); println!("please go to the below link and copy and past the token below");
println!( println!("https://anilist.co/api/v2/oauth/authorize?client_id=9121&response_type=token");
"https://anilist.co/api/v2/oauth/authorize?client_id=9121&response_type=token"
);
let token = string_input("token: "); let token = string_input("token: ");
fs::write(&token_path, token).unwrap(); fs::write(&token_path, token).unwrap();
} }
}
let token = fs::read_to_string(&token_path).unwrap(); let token = fs::read_to_string(&token_path).unwrap();
token token
} }