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

Main Security Shield updates #377

Merged
merged 8 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions crates/profile/logic/logic_SPLIT_ME/src/logic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ mod persona;
mod profile_header;
mod profile_network;
mod profile_networks;
mod profile_security_structure;
mod profile_update;
mod query_factor_sources;

Expand All @@ -18,5 +19,6 @@ pub use persona::*;
pub use profile_header::*;
pub use profile_network::*;
pub use profile_networks::*;
pub use profile_security_structure::*;
pub use profile_update::*;
pub use query_factor_sources::*;
Copy link
Contributor

Choose a reason for hiding this comment

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

imo this can go under the app_preferences/security_structures/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agree 👍

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use crate::prelude::*;

pub trait ProfileHasAnyMainSecurityStructure {
/// Returns true if the profile has any main security structure.
fn has_any_main_security_structure(&self) -> bool;
}

impl ProfileHasAnyMainSecurityStructure for Profile {
/// Returns true if the profile has any main security structure.
fn has_any_main_security_structure(&self) -> bool {
self.app_preferences
.security
.security_structures_of_factor_source_ids
.iter()
.any(|s| s.is_main())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,9 @@ impl<FACTOR> AbstractSecurityStructure<FACTOR> {
)
}
}

impl<FACTOR> AbstractSecurityStructure<FACTOR> {
pub fn is_main(&self) -> bool {
self.metadata.is_main()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,7 @@ impl OsSecurityStructuresQuerying for SargonOS {
))
.await;

if !self
.profile()?
.app_preferences
.security
.security_structures_of_factor_source_ids
.iter()
.any(|s| s.metadata.is_main())
{
if !self.profile()?.has_any_main_security_structure() {
self.set_main_security_structure(id).await?;
}
Ok(())
Expand Down
Loading