use platform_auth::{ DEFAULT_WECHAT_ACCESS_TOKEN_ENDPOINT, DEFAULT_WECHAT_AUTHORIZE_ENDPOINT, DEFAULT_WECHAT_JS_CODE_SESSION_ENDPOINT, DEFAULT_WECHAT_PHONE_NUMBER_ENDPOINT, DEFAULT_WECHAT_STABLE_ACCESS_TOKEN_ENDPOINT, DEFAULT_WECHAT_USER_INFO_ENDPOINT, WechatAuthConfig, WechatProvider, }; use crate::config::AppConfig; pub fn build_wechat_provider(config: &AppConfig) -> WechatProvider { WechatProvider::new(WechatAuthConfig::new( config.wechat_auth_enabled, config.wechat_auth_provider.clone(), config.wechat_app_id.clone(), config.wechat_app_secret.clone(), config.wechat_mini_program_app_id.clone(), config.wechat_mini_program_app_secret.clone(), normalize_wechat_endpoint( &config.wechat_authorize_endpoint, DEFAULT_WECHAT_AUTHORIZE_ENDPOINT, ), normalize_wechat_endpoint( &config.wechat_access_token_endpoint, DEFAULT_WECHAT_ACCESS_TOKEN_ENDPOINT, ), normalize_wechat_endpoint( &config.wechat_user_info_endpoint, DEFAULT_WECHAT_USER_INFO_ENDPOINT, ), normalize_wechat_endpoint( &config.wechat_js_code_session_endpoint, DEFAULT_WECHAT_JS_CODE_SESSION_ENDPOINT, ), normalize_wechat_endpoint( &config.wechat_stable_access_token_endpoint, DEFAULT_WECHAT_STABLE_ACCESS_TOKEN_ENDPOINT, ), normalize_wechat_endpoint( &config.wechat_phone_number_endpoint, DEFAULT_WECHAT_PHONE_NUMBER_ENDPOINT, ), config.wechat_mock_user_id.clone(), config.wechat_mock_union_id.clone(), config.wechat_mock_display_name.clone(), config.wechat_mock_avatar_url.clone(), )) } fn normalize_wechat_endpoint(value: &str, fallback: &str) -> String { let trimmed = value.trim(); if trimmed.is_empty() { fallback.to_string() } else { trimmed.to_string() } }