Browse Source
fix hibp username encoding and pw hint check (#5180)
* fix hibp username encoding
Signed-off-by: BlackDex <black.dex@gmail.com>
* Fix password-hint check
Signed-off-by: BlackDex <black.dex@gmail.com>
---------
Signed-off-by: BlackDex <black.dex@gmail.com>
pull/5184/head
Mathijs van Veluw
2 months ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
2 additions and
2 deletions
-
src/api/core/accounts.rs
-
src/api/core/mod.rs
|
@ -842,7 +842,7 @@ struct PasswordHintData { |
|
|
|
|
|
|
|
|
#[post("/accounts/password-hint", data = "<data>")] |
|
|
#[post("/accounts/password-hint", data = "<data>")] |
|
|
async fn password_hint(data: Json<PasswordHintData>, mut conn: DbConn) -> EmptyResult { |
|
|
async fn password_hint(data: Json<PasswordHintData>, mut conn: DbConn) -> EmptyResult { |
|
|
if !CONFIG.mail_enabled() && !CONFIG.show_password_hint() { |
|
|
if !CONFIG.mail_enabled() || !CONFIG.show_password_hint() { |
|
|
err!("This server is not configured to provide password hints."); |
|
|
err!("This server is not configured to provide password hints."); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
@ -136,8 +136,8 @@ async fn put_eq_domains(data: Json<EquivDomainData>, headers: Headers, conn: DbC |
|
|
|
|
|
|
|
|
#[get("/hibp/breach?<username>")] |
|
|
#[get("/hibp/breach?<username>")] |
|
|
async fn hibp_breach(username: &str, _headers: Headers) -> JsonResult { |
|
|
async fn hibp_breach(username: &str, _headers: Headers) -> JsonResult { |
|
|
if let Some(api_key) = crate::CONFIG.hibp_api_key() { |
|
|
|
|
|
let username: String = url::form_urlencoded::byte_serialize(username.as_bytes()).collect(); |
|
|
let username: String = url::form_urlencoded::byte_serialize(username.as_bytes()).collect(); |
|
|
|
|
|
if let Some(api_key) = crate::CONFIG.hibp_api_key() { |
|
|
let url = format!( |
|
|
let url = format!( |
|
|
"https://haveibeenpwned.com/api/v3/breachedaccount/{username}?truncateResponse=false&includeUnverified=false" |
|
|
"https://haveibeenpwned.com/api/v3/breachedaccount/{username}?truncateResponse=false&includeUnverified=false" |
|
|
); |
|
|
); |
|
|