-
-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: parse user-agent device info #402
Conversation
src/headers.rs
Outdated
} | ||
|
||
pub fn get_device_type(user_agent_client: Option<Client>) -> String { | ||
let mut device_type = "".to_string(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let mut device_type = "".to_string(); | |
let mut device_type = String::new(); |
src/headers.rs
Outdated
context | ||
} | ||
|
||
pub fn get_user_agent_device(user_agent_client: Client) -> String { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub fn get_user_agent_device(user_agent_client: Client) -> String { | |
pub fn get_user_agent_device(user_agent_client: &Client) -> String { |
src/headers.rs
Outdated
let mut context = Context::new(); | ||
|
||
if let Some(client) = user_agent_client { | ||
let device_type = get_user_agent_device(client.clone()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let device_type = get_user_agent_device(client.clone()); | |
let device_type = get_user_agent_device(&client); |
src/headers.rs
Outdated
} | ||
|
||
pub fn get_user_agent_device(user_agent_client: Client) -> String { | ||
let device_type = match user_agent_client.device.model { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let device_type = match user_agent_client.device.model { | |
let device_type = user_agent_client.device.model.unwrap_or("unknown model"); |
src/headers.rs
Outdated
None => "".to_string(), | ||
}; | ||
|
||
let device_os_major = match user_agent_client.os.major { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let device_os_major = match user_agent_client.os.major { | |
let device_version = String::new(); | |
if let Some(major) = user_agent_client.os.major { | |
device_version.push(major); | |
if let Some(minor) = user_agent_client.os.minor { | |
device_version.push('.'); | |
device_version.push(minor); | |
if let Some(patch) = user_agent_client.os.patch { | |
device_version.push('.'); | |
device_version.push(patch); | |
} | |
} | |
} |
src/templates.rs
Outdated
) -> Result<String, TemplateError> { | ||
let (mut tera, mut context) = get_base_tera(None)?; | ||
context.insert("device_name", device_name); | ||
context.insert("public_key", public_key); | ||
context.insert("locations", template_locations); | ||
|
||
if device_type.is_some() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nie powinno być if let Some(device_type) = device_type {
?
Cargo.toml
Outdated
@@ -81,6 +81,7 @@ webauthn-rs = { version = "0.4", features = [ | |||
] } | |||
webauthn-rs-proto = "0.4" | |||
x25519-dalek = { version = "2.0", features = ["static_secrets"] } | |||
uaparser = "0.6.1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uaparser = "0.6.1" | |
uaparser = "0.6" |
No description provided.