Skip to content

Commit

Permalink
minor
Browse files Browse the repository at this point in the history
  • Loading branch information
racnan committed Jan 30, 2024
1 parent d014065 commit 34e000d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
2 changes: 0 additions & 2 deletions crates/router/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,8 @@ pub const ROUTING_CONFIG_ID_LENGTH: usize = 10;
pub const LOCKER_REDIS_PREFIX: &str = "LOCKER_PM_TOKEN";
pub const LOCKER_REDIS_EXPIRY_SECONDS: u32 = 60 * 15; // 15 minutes

// #[cfg(any(feature = "olap", feature = "oltp"))]
pub const JWT_TOKEN_TIME_IN_SECS: u64 = 60 * 60 * 24 * 2; // 2 days

// #[cfg(any(feature = "olap", feature = "oltp"))]
pub const USER_BLACKLIST_PREFIX: &str = "BU_";

#[cfg(feature = "email")]
Expand Down
13 changes: 7 additions & 6 deletions crates/router/src/services/authentication/blacklist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,25 @@ use common_utils::date_time;
use error_stack::{IntoReport, ResultExt};
use redis_interface::RedisConnectionPool;

#[cfg(feature = "olap")]
use crate::core::errors::{UserErrors, UserResult};
#[cfg(feature = "olap")]
use crate::routes::AppState;
use crate::{
consts::{JWT_TOKEN_TIME_IN_SECS, USER_BLACKLIST_PREFIX},
core::errors::{ApiErrorResponse, RouterResult},
routes::app::AppStateInfo,
};
#[cfg(feature = "olap")]
use crate::{
core::errors::{UserErrors, UserResult},
routes::AppState,
};

#[cfg(feature = "olap")]
pub async fn insert_user_in_blacklist(state: &AppState, user_id: &str) -> UserResult<()> {
let token = format!("{}{}", USER_BLACKLIST_PREFIX, user_id);
let user_blacklist_key = format!("{}{}", USER_BLACKLIST_PREFIX, user_id);
let expiry =
expiry_to_i64(JWT_TOKEN_TIME_IN_SECS).change_context(UserErrors::InternalServerError)?;
let redis_conn = get_redis_connection(state).change_context(UserErrors::InternalServerError)?;
redis_conn
.set_key_with_expiry(token.as_str(), date_time::now_unix_timestamp(), expiry)
.set_key_with_expiry(user_blacklist_key.as_str(), date_time::now_unix_timestamp(), expiry)
.await
.change_context(UserErrors::InternalServerError)
}
Expand Down
2 changes: 1 addition & 1 deletion crates/router_env/src/logger/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ pub enum Flow {
FrmFulfillment,
/// Change password flow
ChangePassword,
/// Signout Flow
/// Signout flow
Signout,
/// Set Dashboard Metadata flow
SetDashboardMetadata,
Expand Down

0 comments on commit 34e000d

Please sign in to comment.