mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-30 09:38:33 +08:00
fix(users): revert using mget in authorization (#3999)
This commit is contained in:
@ -80,25 +80,19 @@ pub async fn check_user_in_blacklist<A: AppStateInfo>(
|
|||||||
.map(|timestamp| timestamp.map_or(false, |timestamp| timestamp > token_issued_at))
|
.map(|timestamp| timestamp.map_or(false, |timestamp| timestamp > token_issued_at))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn check_user_and_role_in_blacklist<A: AppStateInfo>(
|
pub async fn check_role_in_blacklist<A: AppStateInfo>(
|
||||||
state: &A,
|
state: &A,
|
||||||
user_id: &str,
|
|
||||||
role_id: &str,
|
role_id: &str,
|
||||||
token_expiry: u64,
|
token_expiry: u64,
|
||||||
) -> RouterResult<bool> {
|
) -> RouterResult<bool> {
|
||||||
let user_token = format!("{}{}", USER_BLACKLIST_PREFIX, user_id);
|
let token = format!("{}{}", ROLE_BLACKLIST_PREFIX, role_id);
|
||||||
let role_token = format!("{}{}", ROLE_BLACKLIST_PREFIX, role_id);
|
|
||||||
let token_issued_at = expiry_to_i64(token_expiry - JWT_TOKEN_TIME_IN_SECS)?;
|
let token_issued_at = expiry_to_i64(token_expiry - JWT_TOKEN_TIME_IN_SECS)?;
|
||||||
let redis_conn = get_redis_connection(state)?;
|
let redis_conn = get_redis_connection(state)?;
|
||||||
|
redis_conn
|
||||||
Ok(redis_conn
|
.get_key::<Option<i64>>(token.as_str())
|
||||||
.get_multiple_keys::<Vec<&str>, i64>(vec![user_token.as_str(), role_token.as_str()])
|
|
||||||
.await
|
.await
|
||||||
.change_context(ApiErrorResponse::InternalServerError)?
|
.change_context(ApiErrorResponse::InternalServerError)
|
||||||
.into_iter()
|
.map(|timestamp| timestamp.map_or(false, |timestamp| timestamp > token_issued_at))
|
||||||
.max()
|
|
||||||
.flatten()
|
|
||||||
.map_or(false, |timestamp| timestamp > token_issued_at))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "email")]
|
#[cfg(feature = "email")]
|
||||||
@ -156,7 +150,10 @@ impl BlackList for AuthToken {
|
|||||||
where
|
where
|
||||||
A: AppStateInfo + Sync,
|
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?,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user