diff --git a/README.md b/README.md index 6adf0a8..ab6a6ee 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ These instructions are assuming the user is stored in the database, if you use L 2. Create a bcrypt password hash for the new user: ```shell -$ htpasswd -nB +$ htpasswd -nB ``` 3. Insert the new user's email, password hash into the `user_logins` table. The salt is not used, so you can put whatever there diff --git a/src/api/auth.rs b/src/api/auth.rs index 6abd0b2..a19b60a 100644 --- a/src/api/auth.rs +++ b/src/api/auth.rs @@ -245,14 +245,20 @@ pub async fn auth_basic_get( return Err(StatusCode::BAD_REQUEST); } + } else { + auth.user = Some(account.clone()); } auth.account = Some(account.clone()); + } else { + debug!("Account was not provided through params"); } // Get service from query string if let Some(service) = params.get("service") { auth.service = Some(service.clone()); + } else { + debug!("Service was not provided through params"); } // Get offline token and attempt to convert it to a boolean @@ -260,6 +266,8 @@ pub async fn auth_basic_get( if let Ok(b) = offline_token.parse::() { auth.offline_token = Some(b); } + } else { + debug!("Offline Token was not provided through params"); } if let Some(client_id) = params.get("client_id") { @@ -268,7 +276,15 @@ pub async fn auth_basic_get( debug!("Constructed auth request"); - if let (Some(account), Some(password)) = (&auth.account, auth.password) { + if auth.account.is_none() { + debug!("Account is none"); + } + + if auth.password.is_none() { + debug!("Password is none"); + } + + if let (Some(account), Some(password)) = (&auth.user, auth.password) { // Ensure that the password is correct let mut auth_driver = state.auth_checker.lock().await; if !auth_driver @@ -346,5 +362,5 @@ pub async fn auth_basic_get( info!("Auth failure! Not enough information given to create auth token!"); // If we didn't get fields required to make a token, then the client did something bad - Err(StatusCode::UNAUTHORIZED) + Err(StatusCode::BAD_REQUEST) }