From 0691c5a17770e7af728b69b84fff0d0bacd80334 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Sun, 7 Apr 2024 15:20:04 +0200 Subject: [PATCH] finish --- Cargo.lock | 12 ++++++------ kitsune/src/http/handler/oauth/authorize.rs | 9 ++++++--- kitsune/src/http/handler/oauth/token.rs | 5 ++++- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4605316ec..f29bbbb9d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1195,9 +1195,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.90" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" +checksum = "1fd97381a8cc6493395a5afc4c691c1084b3768db713b73aa215217aa245d153" [[package]] name = "cfg-if" @@ -2803,9 +2803,9 @@ dependencies = [ [[package]] name = "half" -version = "2.4.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5eceaaeec696539ddaf7b333340f1af35a5aa87ae3e4f3ead0532f72affab2e" +checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888" dependencies = [ "cfg-if", "crunchy", @@ -9048,9 +9048,9 @@ dependencies = [ [[package]] name = "widestring" -version = "1.0.2" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "653f141f39ec16bba3c5abe400a0c60da7468261cc2cbf36805022876bc721a8" +checksum = "7219d36b6eac893fa81e84ebe06485e7dcbb616177469b142df14f1f4deb1311" [[package]] name = "winapi" diff --git a/kitsune/src/http/handler/oauth/authorize.rs b/kitsune/src/http/handler/oauth/authorize.rs index 88879aabd..0555941f9 100644 --- a/kitsune/src/http/handler/oauth/authorize.rs +++ b/kitsune/src/http/handler/oauth/authorize.rs @@ -25,6 +25,9 @@ use oxide_auth_axum::{OAuthRequest, OAuthResponse}; use serde::Deserialize; use speedy_uuid::Uuid; +const UNCONFIRMED_EMAIL_ADDRESS: &str = "Email address is unconfirmed. Check your inbox!"; +const WRONG_EMAIL_OR_PASSWORD: &str = "Entered wrong email or password"; + #[cfg(feature = "oidc")] use { axum::extract::Query, @@ -129,14 +132,14 @@ pub async fn post( let Some(user) = user else { return Ok(Either::E2(( - flash.error(Error::PasswordMismatch.to_string()), + flash.error(WRONG_EMAIL_OR_PASSWORD), Redirect::to(redirect_to), ))); }; if user.confirmed_at.is_none() { return Ok(Either::E2(( - flash.error(Error::UnconfirmedEmailAddress.to_string()), + flash.error(UNCONFIRMED_EMAIL_ADDRESS), Redirect::to(redirect_to), ))); } @@ -155,7 +158,7 @@ pub async fn post( if !is_valid { return Ok(Either::E2(( - flash.error(Error::PasswordMismatch.to_string()), + flash.error(WRONG_EMAIL_OR_PASSWORD), Redirect::to(redirect_to), ))); } diff --git a/kitsune/src/http/handler/oauth/token.rs b/kitsune/src/http/handler/oauth/token.rs index 6d9e7a739..4eadf14c8 100644 --- a/kitsune/src/http/handler/oauth/token.rs +++ b/kitsune/src/http/handler/oauth/token.rs @@ -33,7 +33,10 @@ pub async fn post( let mut flow = RefreshFlow::prepare(oauth_endpoint)?; RefreshFlow::execute(&mut flow, oauth_req).await } - _ => Err(OAuth2Error::UnknownGrantType), + _ => Err(kitsune_error!( + type = ErrorType::BadRequest(Some("unknown grant type".into())), + format!("unknown grant type: {grant_type}") + )), } .map_err(Error::from) }