Browse Source

refactor is_mobile to device

pull/6153/head
Stefan Melmuk 5 days ago
parent
commit
8c7065aa48
No known key found for this signature in database GPG Key ID: 817020C608FE9C09
  1. 2
      src/auth.rs
  2. 8
      src/db/models/device.rs

2
src/auth.rs

@ -1174,7 +1174,7 @@ impl AuthTokens {
let access_claims = LoginJwtClaims::default(device, user, &sub, client_id); 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 *MOBILE_REFRESH_VALIDITY
} else { } else {
*DEFAULT_REFRESH_VALIDITY *DEFAULT_REFRESH_VALIDITY

8
src/db/models/device.rs

@ -70,6 +70,10 @@ impl Device {
pub fn is_cli(&self) -> bool { pub fn is_cli(&self) -> bool {
matches!(DeviceType::from_i32(self.atype), DeviceType::WindowsCLI | DeviceType::MacOsCLI | DeviceType::LinuxCLI) 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 { pub struct DeviceWithAuthRequest {
@ -353,10 +357,6 @@ impl DeviceType {
_ => DeviceType::UnknownBrowser, _ => DeviceType::UnknownBrowser,
} }
} }
pub fn is_mobile(value: &i32) -> bool {
*value == DeviceType::Android as i32 || *value == DeviceType::Ios as i32
}
} }
#[derive( #[derive(

Loading…
Cancel
Save