Skip to content

Commit

Permalink
Shield Sea ORM: Fix subprovider slug filter
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielleHuisman committed Dec 29, 2024
1 parent 0fd3769 commit 5370809
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/storage/shield-sea-orm/src/providers/oidc.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use async_trait::async_trait;
use sea_orm::{ActiveModelTrait, ActiveValue, ColumnTrait, Condition, EntityTrait, QueryFilter};
use sea_orm::{ActiveModelTrait, ActiveValue, ColumnTrait, EntityTrait, QueryFilter};
use shield::StorageError;
use shield_oidc::{
CreateOidcConnection, OidcConnection, OidcProviderPkceCodeChallenge, OidcProviderVisibility,
Expand Down Expand Up @@ -31,12 +31,13 @@ impl OidcStorage<User> for SeaOrmStorage {
&self,
subprovider_id: &str,
) -> Result<Option<OidcSubprovider>, StorageError> {
let condition = match Self::parse_uuid(subprovider_id) {
Ok(subprovider_id) => oidc_provider::Column::Id.eq(subprovider_id),
Err(_) => oidc_provider::Column::Slug.eq(subprovider_id.to_lowercase()),
};

oidc_provider::Entity::find()
.filter(
Condition::any()
.add(oidc_provider::Column::Id.eq(Self::parse_uuid(subprovider_id)?))
.add(oidc_provider::Column::Slug.eq(subprovider_id.to_lowercase())),
)
.filter(condition)
.one(&self.database)
.await
.map_err(|err| StorageError::Engine(err.to_string()))
Expand Down

0 comments on commit 5370809

Please sign in to comment.