Skip to content

Commit de896f8

Browse files
committed
refactor: check subscription
1 parent 3d57a62 commit de896f8

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

src-tauri/src/cloud_auth.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,11 +602,24 @@ impl CloudAuthManager {
602602
pub async fn has_active_paid_subscription(&self) -> bool {
603603
let state = self.state.lock().await;
604604
match &*state {
605-
Some(auth) => auth.user.plan != "free" && auth.user.subscription_status == "active",
605+
Some(auth) => {
606+
auth.user.plan != "free"
607+
&& (auth.user.subscription_status == "active"
608+
|| auth.user.plan_period.as_deref() == Some("lifetime"))
609+
}
606610
None => false,
607611
}
608612
}
609613

614+
pub async fn is_fingerprint_os_allowed(&self, fingerprint_os: Option<&str>) -> bool {
615+
let host_os = crate::profile::types::get_host_os();
616+
match fingerprint_os {
617+
None => true,
618+
Some(os) if os == host_os => true,
619+
Some(_) => self.has_active_paid_subscription().await,
620+
}
621+
}
622+
610623
pub async fn get_user(&self) -> Option<CloudAuthState> {
611624
let state = self.state.lock().await;
612625
state.clone()

src-tauri/src/profile/manager.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1902,6 +1902,18 @@ pub async fn create_browser_profile_new(
19021902
wayfern_config: Option<WayfernConfig>,
19031903
group_id: Option<String>,
19041904
) -> Result<BrowserProfile, String> {
1905+
let fingerprint_os = camoufox_config
1906+
.as_ref()
1907+
.and_then(|c| c.os.as_deref())
1908+
.or_else(|| wayfern_config.as_ref().and_then(|c| c.os.as_deref()));
1909+
1910+
if !crate::cloud_auth::CLOUD_AUTH
1911+
.is_fingerprint_os_allowed(fingerprint_os)
1912+
.await
1913+
{
1914+
return Err("Fingerprint OS spoofing requires an active Pro subscription".to_string());
1915+
}
1916+
19051917
let browser_type =
19061918
BrowserType::from_str(&browser_str).map_err(|e| format!("Invalid browser type: {e}"))?;
19071919
create_browser_profile_with_group(
@@ -1924,6 +1936,13 @@ pub async fn update_camoufox_config(
19241936
profile_id: String,
19251937
config: CamoufoxConfig,
19261938
) -> Result<(), String> {
1939+
if !crate::cloud_auth::CLOUD_AUTH
1940+
.is_fingerprint_os_allowed(config.os.as_deref())
1941+
.await
1942+
{
1943+
return Err("Fingerprint OS spoofing requires an active Pro subscription".to_string());
1944+
}
1945+
19271946
let profile_manager = ProfileManager::instance();
19281947
profile_manager
19291948
.update_camoufox_config(app_handle, &profile_id, config)
@@ -1937,6 +1956,13 @@ pub async fn update_wayfern_config(
19371956
profile_id: String,
19381957
config: WayfernConfig,
19391958
) -> Result<(), String> {
1959+
if !crate::cloud_auth::CLOUD_AUTH
1960+
.is_fingerprint_os_allowed(config.os.as_deref())
1961+
.await
1962+
{
1963+
return Err("Fingerprint OS spoofing requires an active Pro subscription".to_string());
1964+
}
1965+
19401966
let profile_manager = ProfileManager::instance();
19411967
profile_manager
19421968
.update_wayfern_config(app_handle, &profile_id, config)

0 commit comments

Comments
 (0)