Fix admin login and add subscription popup settings
Some checks failed
docker-images / build-and-push (admin, admin, termi-astro-admin, admin/Dockerfile) (push) Failing after 6s
docker-images / build-and-push (backend, backend, termi-astro-backend, backend/Dockerfile) (push) Failing after 5s
docker-images / build-and-push (frontend, frontend, termi-astro-frontend, frontend/Dockerfile) (push) Failing after 6s
Some checks failed
docker-images / build-and-push (admin, admin, termi-astro-admin, admin/Dockerfile) (push) Failing after 6s
docker-images / build-and-push (backend, backend, termi-astro-backend, backend/Dockerfile) (push) Failing after 5s
docker-images / build-and-push (frontend, frontend, termi-astro-frontend, frontend/Dockerfile) (push) Failing after 6s
This commit is contained in:
@@ -44,8 +44,13 @@ pub struct AdminSessionResponse {
|
||||
pub can_logout: bool,
|
||||
}
|
||||
|
||||
fn build_session_response(identity: Option<crate::controllers::admin::AdminIdentity>) -> AdminSessionResponse {
|
||||
let can_logout = matches!(identity.as_ref().map(|item| item.source.as_str()), Some("local"));
|
||||
fn build_session_response(
|
||||
identity: Option<crate::controllers::admin::AdminIdentity>,
|
||||
) -> AdminSessionResponse {
|
||||
let can_logout = matches!(
|
||||
identity.as_ref().map(|item| item.source.as_str()),
|
||||
Some("local")
|
||||
);
|
||||
|
||||
AdminSessionResponse {
|
||||
authenticated: identity.is_some(),
|
||||
@@ -193,6 +198,10 @@ pub struct AdminSiteSettingsResponse {
|
||||
pub notification_webhook_url: Option<String>,
|
||||
pub notification_comment_enabled: bool,
|
||||
pub notification_friend_link_enabled: bool,
|
||||
pub subscription_popup_enabled: bool,
|
||||
pub subscription_popup_title: String,
|
||||
pub subscription_popup_description: String,
|
||||
pub subscription_popup_delay_seconds: i32,
|
||||
pub search_synonyms: Vec<String>,
|
||||
}
|
||||
|
||||
@@ -706,6 +715,18 @@ fn build_settings_response(
|
||||
notification_webhook_url: item.notification_webhook_url,
|
||||
notification_comment_enabled: item.notification_comment_enabled.unwrap_or(false),
|
||||
notification_friend_link_enabled: item.notification_friend_link_enabled.unwrap_or(false),
|
||||
subscription_popup_enabled: item
|
||||
.subscription_popup_enabled
|
||||
.unwrap_or_else(site_settings::default_subscription_popup_enabled),
|
||||
subscription_popup_title: item
|
||||
.subscription_popup_title
|
||||
.unwrap_or_else(site_settings::default_subscription_popup_title),
|
||||
subscription_popup_description: item
|
||||
.subscription_popup_description
|
||||
.unwrap_or_else(site_settings::default_subscription_popup_description),
|
||||
subscription_popup_delay_seconds: item
|
||||
.subscription_popup_delay_seconds
|
||||
.unwrap_or_else(site_settings::default_subscription_popup_delay_seconds),
|
||||
search_synonyms: tech_stack_values(&item.search_synonyms),
|
||||
}
|
||||
}
|
||||
@@ -753,7 +774,10 @@ pub async fn session_login(
|
||||
#[debug_handler]
|
||||
pub async fn session_logout(headers: HeaderMap, State(ctx): State<AppContext>) -> Result<Response> {
|
||||
let before = resolve_admin_identity(&headers);
|
||||
if matches!(before.as_ref().map(|item| item.source.as_str()), Some("local")) {
|
||||
if matches!(
|
||||
before.as_ref().map(|item| item.source.as_str()),
|
||||
Some("local")
|
||||
) {
|
||||
clear_local_session(&headers);
|
||||
}
|
||||
|
||||
@@ -764,7 +788,10 @@ pub async fn session_logout(headers: HeaderMap, State(ctx): State<AppContext>) -
|
||||
"admin.logout",
|
||||
"admin_session",
|
||||
None,
|
||||
identity.email.clone().or_else(|| Some(identity.username.clone())),
|
||||
identity
|
||||
.email
|
||||
.clone()
|
||||
.or_else(|| Some(identity.username.clone())),
|
||||
None,
|
||||
)
|
||||
.await?;
|
||||
@@ -843,10 +870,7 @@ pub async fn dashboard(headers: HeaderMap, State(ctx): State<AppContext>) -> Res
|
||||
}
|
||||
}
|
||||
|
||||
let mut recent_posts = all_posts
|
||||
.clone()
|
||||
.into_iter()
|
||||
.collect::<Vec<_>>();
|
||||
let mut recent_posts = all_posts.clone().into_iter().collect::<Vec<_>>();
|
||||
recent_posts.sort_by(|left, right| right.created_at.cmp(&left.created_at));
|
||||
let recent_posts = recent_posts
|
||||
.into_iter()
|
||||
@@ -959,13 +983,19 @@ pub async fn dashboard(headers: HeaderMap, State(ctx): State<AppContext>) -> Res
|
||||
}
|
||||
|
||||
#[debug_handler]
|
||||
pub async fn analytics_overview(headers: HeaderMap, State(ctx): State<AppContext>) -> Result<Response> {
|
||||
pub async fn analytics_overview(
|
||||
headers: HeaderMap,
|
||||
State(ctx): State<AppContext>,
|
||||
) -> Result<Response> {
|
||||
check_auth(&headers)?;
|
||||
format::json(analytics::build_admin_analytics(&ctx).await?)
|
||||
}
|
||||
|
||||
#[debug_handler]
|
||||
pub async fn get_site_settings(headers: HeaderMap, State(ctx): State<AppContext>) -> Result<Response> {
|
||||
pub async fn get_site_settings(
|
||||
headers: HeaderMap,
|
||||
State(ctx): State<AppContext>,
|
||||
) -> Result<Response> {
|
||||
check_auth(&headers)?;
|
||||
let current = site_settings::load_current(&ctx).await?;
|
||||
let ai_chunks_count = ai_chunks::Entity::find().count(&ctx.db).await?;
|
||||
@@ -1061,7 +1091,10 @@ pub async fn test_ai_image_provider(
|
||||
}
|
||||
|
||||
#[debug_handler]
|
||||
pub async fn test_r2_storage(headers: HeaderMap, State(ctx): State<AppContext>) -> Result<Response> {
|
||||
pub async fn test_r2_storage(
|
||||
headers: HeaderMap,
|
||||
State(ctx): State<AppContext>,
|
||||
) -> Result<Response> {
|
||||
check_auth(&headers)?;
|
||||
|
||||
let settings = storage::require_r2_settings(&ctx).await?;
|
||||
@@ -1278,7 +1311,10 @@ pub async fn replace_media_object(
|
||||
}
|
||||
|
||||
#[debug_handler]
|
||||
pub async fn list_comment_blacklist(headers: HeaderMap, State(ctx): State<AppContext>) -> Result<Response> {
|
||||
pub async fn list_comment_blacklist(
|
||||
headers: HeaderMap,
|
||||
State(ctx): State<AppContext>,
|
||||
) -> Result<Response> {
|
||||
check_auth(&headers)?;
|
||||
|
||||
let items = comment_blacklist::Entity::find()
|
||||
|
||||
Reference in New Issue
Block a user