From 8c7065aa48ff7b5004f87b2d5921f5564b294cf4 Mon Sep 17 00:00:00 2001 From: Stefan Melmuk Date: Sat, 9 Aug 2025 00:05:21 +0200 Subject: [PATCH] refactor is_mobile to device --- src/auth.rs | 2 +- src/db/models/device.rs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/auth.rs b/src/auth.rs index 1a602a5c..a4a0b22c 100644 --- a/src/auth.rs +++ b/src/auth.rs @@ -1174,7 +1174,7 @@ impl AuthTokens { let access_claims = LoginJwtClaims::default(device, user, &sub, client_id); - let validity = if DeviceType::is_mobile(&device.atype) { + let validity = if device.is_mobile() { *MOBILE_REFRESH_VALIDITY } else { *DEFAULT_REFRESH_VALIDITY diff --git a/src/db/models/device.rs b/src/db/models/device.rs index 91cc1e18..005d942d 100644 --- a/src/db/models/device.rs +++ b/src/db/models/device.rs @@ -70,6 +70,10 @@ impl Device { pub fn is_cli(&self) -> bool { matches!(DeviceType::from_i32(self.atype), DeviceType::WindowsCLI | DeviceType::MacOsCLI | DeviceType::LinuxCLI) } + + pub fn is_mobile(&self) -> bool { + matches!(DeviceType::from_i32(self.atype), DeviceType::Android | DeviceType::Ios) + } } pub struct DeviceWithAuthRequest { @@ -353,10 +357,6 @@ impl DeviceType { _ => DeviceType::UnknownBrowser, } } - - pub fn is_mobile(value: &i32) -> bool { - *value == DeviceType::Android as i32 || *value == DeviceType::Ios as i32 - } } #[derive(