Cleaning up oauth providers conversion. (#5280)

* Cleaning up oauth providers conversion.

* Use into_iter
This commit is contained in:
Dessalines 2024-12-27 12:52:05 -05:00 committed by GitHub
parent cc190aefdf
commit 76034f058d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -55,13 +55,11 @@ impl OAuthProvider {
pub fn convert_providers_to_public( pub fn convert_providers_to_public(
oauth_providers: Vec<OAuthProvider>, oauth_providers: Vec<OAuthProvider>,
) -> Vec<PublicOAuthProvider> { ) -> Vec<PublicOAuthProvider> {
let mut result = Vec::<PublicOAuthProvider>::new(); oauth_providers
for oauth_provider in &oauth_providers { .into_iter()
if oauth_provider.enabled { .filter(|x| x.enabled)
result.push(PublicOAuthProvider(oauth_provider.clone())); .map(PublicOAuthProvider)
} .collect()
}
result
} }
pub async fn get_all_public(pool: &mut DbPool<'_>) -> Result<Vec<PublicOAuthProvider>, Error> { pub async fn get_all_public(pool: &mut DbPool<'_>) -> Result<Vec<PublicOAuthProvider>, Error> {