Skip to content

Commit

Permalink
finish
Browse files Browse the repository at this point in the history
  • Loading branch information
aumetra committed Apr 7, 2024
1 parent a624c50 commit 0691c5a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions kitsune/src/http/handler/oauth/authorize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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),
)));
}
Expand All @@ -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),
)));
}
Expand Down
5 changes: 4 additions & 1 deletion kitsune/src/http/handler/oauth/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit 0691c5a

Please sign in to comment.