Quantcast
Channel: User Schwern - Stack Overflow
Viewing all articles
Browse latest Browse all 581

Answer by Schwern for Why do I keep having "access denied" although I used correct username and password?

$
0
0

In search_username_in_csv, if stored_username == stored_username{ will always be true, so it will always pick the first line of the CSV.

I think you meant if stored_username == username {


There should have been a warning about the unused username argument. That's the first debugging clue.

warning: unused variable: `username`  --> src/main.rs:45:5   |45 |     username: &str,   |     ^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_username`   |   = note: `#[warn(unused_variables)]` on by default

And we can verify whether verify_password is receiving the expected password and stored_hash.

fn verify_password(password: &str, stored_hash: &str) -> bool {    println!("password: '{}', stored_hash: '{}'", password, stored_hash);

Viewing all articles
Browse latest Browse all 581

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>