pub struct PersonsSettingsTwoFactorResource<'a> { /* private fields */ }Expand description
client.persons().settings().two_factor()
Implementations§
Source§impl<'a> PersonsSettingsTwoFactorResource<'a>
impl<'a> PersonsSettingsTwoFactorResource<'a>
Sourcepub fn create(
&self,
person_id: impl Display,
body: &LoginCredentials,
) -> Result<TwoFactorSetupSecret>
pub fn create( &self, person_id: impl Display, body: &LoginCredentials, ) -> Result<TwoFactorSetupSecret>
Initialize an authenticator for the current person
POST /persons/{personId}/settings/twofactor
Verifies the current person’s username/email and password, then stores a new TOTP secret and sets twoFactorEnabled to false. Only the current person can initialize their own authenticator. Repeating this call replaces the previous secret and disables an already active authenticator. Keep the returned secret or QR code for enrollment, verify a generated code through POST /twofactor/totp, then call PUT on this path to activate. This step does not complete activation.
§Example
let body = models::LoginCredentials {
password: "example-password".into(),
username: "alex@example.org".into(),
..Default::default()
};
let result = client.persons().settings().two_factor().create(42, &body)?;
println!("{}", result.qrcode);Sourcepub fn delete(&self, person_id: impl Display) -> Result<()>
pub fn delete(&self, person_id: impl Display) -> Result<()>
Deactivate the current person’s authenticator
DELETE /persons/{personId}/settings/twofactor
Sets twoFactorEnabled to false and deletes the stored TOTP secret. Only the current person may deactivate their own authenticator. No password or authenticator code is consumed. Repeating the call is allowed. This does not clear an administrator’s twoFactorForce setting or group-role requirements, so a later login can require setup again.
§Example
client.persons().settings().two_factor().delete(42)?;Sourcepub fn get(&self, person_id: impl Display) -> Result<PersonTwoFactorEnabled>
pub fn get(&self, person_id: impl Display) -> Result<PersonTwoFactorEnabled>
Get the person’s two-factor activation setting
GET /persons/{personId}/settings/twofactor
Returns the stored twoFactorEnabled setting, defaulting to false without storing it when absent. Requires access to the person’s settings (self, super administrator or administer persons; the global defaults person -1 is also allowed). This reports activation only, not whether two-factor authentication is required by an administrator or group role.
§Example
let two_factor = client.persons().settings().two_factor().get(42)?;
println!("{}", two_factor.attribute);Sourcepub fn get_force(&self, person_id: impl Display) -> Result<PersonTwoFactorForce>
pub fn get_force(&self, person_id: impl Display) -> Result<PersonTwoFactorForce>
Get the person’s explicit two-factor requirement
GET /persons/{personId}/settings/twofactor/force
Returns the stored twoFactorForce setting, defaulting to false when absent. Requires churchcore administer persons or simulate persons. This is only the explicit person-level flag; an applicable group role may still require two-factor authentication when this value is false.
§Example
let force = client.persons().settings().two_factor().get_force(42)?;
println!("{}", force.attribute);Sourcepub fn update(&self, person_id: impl Display) -> Result<PersonTwoFactorEnabled>
pub fn update(&self, person_id: impl Display) -> Result<PersonTwoFactorEnabled>
Activate the current person’s initialized authenticator
PUT /persons/{personId}/settings/twofactor
Sets twoFactorEnabled to true and refreshes person session data. Only the current person may activate their own authenticator. A stored secret from initialization is required; otherwise 400 is returned. No request body is consumed. Clients should first verify an authenticator code with POST /twofactor/totp; this activation handler itself checks only that a secret exists, not that a code was previously verified. Existing login tokens and other sessions are not revoked.
§Example
let result = client.persons().settings().two_factor().update(42)?;
println!("{}", result.attribute);Sourcepub fn update_force(
&self,
person_id: impl Display,
body: &PersonTwoFactorForceUpdate,
) -> Result<PersonTwoFactorForce>
pub fn update_force( &self, person_id: impl Display, body: &PersonTwoFactorForceUpdate, ) -> Result<PersonTwoFactorForce>
Set the person’s explicit two-factor requirement
PUT /persons/{personId}/settings/twofactor/force
Stores the explicit person-level two-factor requirement. Requires churchcore administer persons or simulate persons; only a super administrator may change this flag for another super administrator. Setting false does not remove a requirement inherited from a group role. This neither enrolls an authenticator nor changes twoFactorEnabled.
§Example
let body = models::PersonTwoFactorForceUpdate {
value: true,
..Default::default()
};
let result = client.persons().settings().two_factor().update_force(42, &body)?;
println!("{}", result.attribute);