|
|
@ -405,7 +405,6 @@ impl<'r> FromRequest<'r> for Host {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub struct ClientHeaders {
|
|
|
|
pub struct ClientHeaders {
|
|
|
|
pub host: String,
|
|
|
|
|
|
|
|
pub device_type: i32,
|
|
|
|
pub device_type: i32,
|
|
|
|
pub ip: ClientIp,
|
|
|
|
pub ip: ClientIp,
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -415,7 +414,6 @@ impl<'r> FromRequest<'r> for ClientHeaders {
|
|
|
|
type Error = &'static str;
|
|
|
|
type Error = &'static str;
|
|
|
|
|
|
|
|
|
|
|
|
async fn from_request(request: &'r Request<'_>) -> Outcome<Self, Self::Error> {
|
|
|
|
async fn from_request(request: &'r Request<'_>) -> Outcome<Self, Self::Error> {
|
|
|
|
let host = try_outcome!(Host::from_request(request).await).host;
|
|
|
|
|
|
|
|
let ip = match ClientIp::from_request(request).await {
|
|
|
|
let ip = match ClientIp::from_request(request).await {
|
|
|
|
Outcome::Success(ip) => ip,
|
|
|
|
Outcome::Success(ip) => ip,
|
|
|
|
_ => err_handler!("Error getting Client IP"),
|
|
|
|
_ => err_handler!("Error getting Client IP"),
|
|
|
@ -425,7 +423,6 @@ impl<'r> FromRequest<'r> for ClientHeaders {
|
|
|
|
request.headers().get_one("device-type").map(|d| d.parse().unwrap_or(14)).unwrap_or_else(|| 14);
|
|
|
|
request.headers().get_one("device-type").map(|d| d.parse().unwrap_or(14)).unwrap_or_else(|| 14);
|
|
|
|
|
|
|
|
|
|
|
|
Outcome::Success(ClientHeaders {
|
|
|
|
Outcome::Success(ClientHeaders {
|
|
|
|
host,
|
|
|
|
|
|
|
|
device_type,
|
|
|
|
device_type,
|
|
|
|
ip,
|
|
|
|
ip,
|
|
|
|
})
|
|
|
|
})
|
|
|
@ -531,7 +528,6 @@ pub struct OrgHeaders {
|
|
|
|
pub user: User,
|
|
|
|
pub user: User,
|
|
|
|
pub org_user_type: UserOrgType,
|
|
|
|
pub org_user_type: UserOrgType,
|
|
|
|
pub org_user: UserOrganization,
|
|
|
|
pub org_user: UserOrganization,
|
|
|
|
pub org_id: String,
|
|
|
|
|
|
|
|
pub ip: ClientIp,
|
|
|
|
pub ip: ClientIp,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -594,7 +590,6 @@ impl<'r> FromRequest<'r> for OrgHeaders {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
org_user,
|
|
|
|
org_user,
|
|
|
|
org_id: String::from(org_id),
|
|
|
|
|
|
|
|
ip: headers.ip,
|
|
|
|
ip: headers.ip,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -671,7 +666,6 @@ pub struct ManagerHeaders {
|
|
|
|
pub host: String,
|
|
|
|
pub host: String,
|
|
|
|
pub device: Device,
|
|
|
|
pub device: Device,
|
|
|
|
pub user: User,
|
|
|
|
pub user: User,
|
|
|
|
pub org_user_type: UserOrgType,
|
|
|
|
|
|
|
|
pub ip: ClientIp,
|
|
|
|
pub ip: ClientIp,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -700,7 +694,6 @@ impl<'r> FromRequest<'r> for ManagerHeaders {
|
|
|
|
host: headers.host,
|
|
|
|
host: headers.host,
|
|
|
|
device: headers.device,
|
|
|
|
device: headers.device,
|
|
|
|
user: headers.user,
|
|
|
|
user: headers.user,
|
|
|
|
org_user_type: headers.org_user_type,
|
|
|
|
|
|
|
|
ip: headers.ip,
|
|
|
|
ip: headers.ip,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -727,7 +720,6 @@ pub struct ManagerHeadersLoose {
|
|
|
|
pub device: Device,
|
|
|
|
pub device: Device,
|
|
|
|
pub user: User,
|
|
|
|
pub user: User,
|
|
|
|
pub org_user: UserOrganization,
|
|
|
|
pub org_user: UserOrganization,
|
|
|
|
pub org_user_type: UserOrgType,
|
|
|
|
|
|
|
|
pub ip: ClientIp,
|
|
|
|
pub ip: ClientIp,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -743,7 +735,6 @@ impl<'r> FromRequest<'r> for ManagerHeadersLoose {
|
|
|
|
device: headers.device,
|
|
|
|
device: headers.device,
|
|
|
|
user: headers.user,
|
|
|
|
user: headers.user,
|
|
|
|
org_user: headers.org_user,
|
|
|
|
org_user: headers.org_user,
|
|
|
|
org_user_type: headers.org_user_type,
|
|
|
|
|
|
|
|
ip: headers.ip,
|
|
|
|
ip: headers.ip,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -782,14 +773,12 @@ impl ManagerHeaders {
|
|
|
|
host: h.host,
|
|
|
|
host: h.host,
|
|
|
|
device: h.device,
|
|
|
|
device: h.device,
|
|
|
|
user: h.user,
|
|
|
|
user: h.user,
|
|
|
|
org_user_type: h.org_user_type,
|
|
|
|
|
|
|
|
ip: h.ip,
|
|
|
|
ip: h.ip,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub struct OwnerHeaders {
|
|
|
|
pub struct OwnerHeaders {
|
|
|
|
pub host: String,
|
|
|
|
|
|
|
|
pub device: Device,
|
|
|
|
pub device: Device,
|
|
|
|
pub user: User,
|
|
|
|
pub user: User,
|
|
|
|
pub ip: ClientIp,
|
|
|
|
pub ip: ClientIp,
|
|
|
@ -803,7 +792,6 @@ impl<'r> FromRequest<'r> for OwnerHeaders {
|
|
|
|
let headers = try_outcome!(OrgHeaders::from_request(request).await);
|
|
|
|
let headers = try_outcome!(OrgHeaders::from_request(request).await);
|
|
|
|
if headers.org_user_type == UserOrgType::Owner {
|
|
|
|
if headers.org_user_type == UserOrgType::Owner {
|
|
|
|
Outcome::Success(Self {
|
|
|
|
Outcome::Success(Self {
|
|
|
|
host: headers.host,
|
|
|
|
|
|
|
|
device: headers.device,
|
|
|
|
device: headers.device,
|
|
|
|
user: headers.user,
|
|
|
|
user: headers.user,
|
|
|
|
ip: headers.ip,
|
|
|
|
ip: headers.ip,
|
|
|
|