[feat] check auth path
This commit is contained in:
@@ -102,14 +102,23 @@ fn check_auth(fpath: String, auth: String) -> bool{
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// read file
|
// read file, return false when error
|
||||||
let got_auth = std::fs::read_to_string(&path).expect("Something went wrong reading the file");
|
let got_auth = std::fs::read_to_string(&path);
|
||||||
|
|
||||||
// check auth
|
// check read error
|
||||||
if got_auth != auth {
|
if got_auth.is_err() {
|
||||||
|
println!("Error reading file {}", path.display());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
else{
|
||||||
|
// check auth
|
||||||
|
if got_auth.unwrap() != auth {
|
||||||
|
println!("Auth does not match");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
println!("Auth matches");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user