Skip to main content

PersonsSettingsTwoFactorResource

Struct PersonsSettingsTwoFactorResource 

Source
pub struct PersonsSettingsTwoFactorResource<'a> { /* private fields */ }
Expand description

client.persons().settings().two_factor()

Implementations§

Source§

impl<'a> PersonsSettingsTwoFactorResource<'a>

Source

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);
Source

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)?;
Source

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);
Source

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);
Source

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);
Source

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);

Trait Implementations§

Source§

impl<'a> Clone for PersonsSettingsTwoFactorResource<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for PersonsSettingsTwoFactorResource<'a>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more