Add check to make sure gateway region = device-profile region.

This commit is contained in:
Orne Brocaar 2022-05-24 20:53:20 +01:00
parent 3486d94441
commit bd79e72bdb
2 changed files with 12 additions and 4 deletions

View File

@ -158,8 +158,12 @@ impl Data {
async fn get_device_profile(&mut self) -> Result<()> { async fn get_device_profile(&mut self) -> Result<()> {
trace!("Getting the device-profile"); trace!("Getting the device-profile");
self.device_profile = let dp = device_profile::get(&self.device.as_ref().unwrap().device_profile_id).await?;
Some(device_profile::get(&self.device.as_ref().unwrap().device_profile_id).await?); if dp.region != self.uplink_frame_set.region_common_name {
return Err(anyhow!("Invalid device-profile region"));
}
self.device_profile = Some(dp);
Ok(()) Ok(())
} }

View File

@ -152,8 +152,12 @@ impl JoinRequest {
async fn get_device_profile(&mut self) -> Result<()> { async fn get_device_profile(&mut self) -> Result<()> {
trace!("Getting device-profile"); trace!("Getting device-profile");
self.device_profile = let dp = device_profile::get(&self.device.as_ref().unwrap().device_profile_id).await?;
Some(device_profile::get(&self.device.as_ref().unwrap().device_profile_id).await?); if dp.region != self.uplink_frame_set.region_common_name {
return Err(anyhow!("Invalid device-profile region"));
}
self.device_profile = Some(dp);
Ok(()) Ok(())
} }