Skip to content
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

Merged
merged 16 commits into from
Nov 13, 2023

Conversation

blazej-teonite
Copy link
Contributor

No description provided.

@blazej-teonite blazej-teonite changed the title Dfg 391 user agent information about device feat: parse user-agent device info Nov 9, 2023
src/headers.rs Outdated
}

pub fn get_device_type(user_agent_client: Option<Client>) -> String {
let mut device_type = "".to_string();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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() {
Copy link
Contributor

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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
uaparser = "0.6.1"
uaparser = "0.6"

@moubctez moubctez merged commit 40637eb into dev Nov 13, 2023
3 checks passed
@moubctez moubctez deleted the DFG-391-user-agent-information-about-device branch November 13, 2023 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants