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