// error #[derive(thiserror::Error)] // the rest #[derive(Debug)] pub enum Error { #[error("Database: {0}")] Database(#[from] database::Error), #[error("Bad response types")] ResponseTypes, #[error("Invalid scopes")] Scopes, #[error("Invalid application")] Application, } use super::App; use database::sqlx::SqliteExecutor; impl App { pub async fn get_valid_app( conn: impl SqliteExecutor<'_>, response_type: &str, scope: &str, client_id: &str, redirect_uri: &str, ) -> Result { // Check for valid response types openid::parse_response_types(response_type).ok_or_else(|| Error::ResponseTypes)?; // Check for supported scopes if !openid::SupportedScopes::check_supported_scopes(scope) { return Err(Error::Scopes); } Self::get_one(conn, client_id, redirect_uri) .await? .ok_or_else(|| Error::Application) } }