diff --git a/crates/router/src/services/authentication/blacklist.rs b/crates/router/src/services/authentication/blacklist.rs index b5cdcaf084..2ee8302be6 100644 --- a/crates/router/src/services/authentication/blacklist.rs +++ b/crates/router/src/services/authentication/blacklist.rs @@ -80,25 +80,19 @@ pub async fn check_user_in_blacklist( .map(|timestamp| timestamp.map_or(false, |timestamp| timestamp > token_issued_at)) } -pub async fn check_user_and_role_in_blacklist( +pub async fn check_role_in_blacklist( state: &A, - user_id: &str, role_id: &str, token_expiry: u64, ) -> RouterResult { - let user_token = format!("{}{}", USER_BLACKLIST_PREFIX, user_id); - let role_token = format!("{}{}", ROLE_BLACKLIST_PREFIX, role_id); + let token = format!("{}{}", ROLE_BLACKLIST_PREFIX, role_id); let token_issued_at = expiry_to_i64(token_expiry - JWT_TOKEN_TIME_IN_SECS)?; let redis_conn = get_redis_connection(state)?; - - Ok(redis_conn - .get_multiple_keys::, i64>(vec![user_token.as_str(), role_token.as_str()]) + redis_conn + .get_key::>(token.as_str()) .await - .change_context(ApiErrorResponse::InternalServerError)? - .into_iter() - .max() - .flatten() - .map_or(false, |timestamp| timestamp > token_issued_at)) + .change_context(ApiErrorResponse::InternalServerError) + .map(|timestamp| timestamp.map_or(false, |timestamp| timestamp > token_issued_at)) } #[cfg(feature = "email")] @@ -156,7 +150,10 @@ impl BlackList for AuthToken { where A: AppStateInfo + Sync, { - check_user_and_role_in_blacklist(state, &self.user_id, &self.role_id, self.exp).await + Ok( + check_user_in_blacklist(state, &self.user_id, self.exp).await? + || check_role_in_blacklist(state, &self.role_id, self.exp).await?, + ) } }