mas_templates/context/
ext.rs1use mas_data_model::SiteConfig;
8
9use super::{SiteBranding, SiteFeatures};
10
11mod private {
12 pub trait Sealed {}
13 impl Sealed for mas_data_model::SiteConfig {}
14}
15
16pub trait SiteConfigExt: private::Sealed {
19 fn templates_branding(&self) -> SiteBranding;
21
22 fn templates_features(&self) -> SiteFeatures;
24}
25
26impl SiteConfigExt for SiteConfig {
27 fn templates_branding(&self) -> SiteBranding {
28 let mut branding = SiteBranding::new(self.server_name.clone());
29
30 if let Some(policy_uri) = &self.policy_uri {
31 branding = branding.with_policy_uri(policy_uri.as_str());
32 }
33
34 if let Some(tos_uri) = &self.tos_uri {
35 branding = branding.with_tos_uri(tos_uri.as_str());
36 }
37
38 if let Some(imprint) = &self.imprint {
39 branding = branding.with_imprint(imprint.as_str());
40 }
41
42 branding
43 }
44
45 fn templates_features(&self) -> SiteFeatures {
46 SiteFeatures {
47 password_registration: self.password_registration_enabled,
48 password_login: self.password_login_enabled,
49 account_recovery: self.account_recovery_allowed,
50 }
51 }
52}