pub struct LoginTwoFactorSetupResource<'a> { /* private fields */ }Expand description
client.login().two_factor().setup()
Implementations§
Source§impl<'a> LoginTwoFactorSetupResource<'a>
impl<'a> LoginTwoFactorSetupResource<'a>
Sourcepub fn activate(
&self,
body: &TwoFactorSetupActivate,
) -> Result<PostLoginTwofactorSetupActivateData>
pub fn activate( &self, body: &TwoFactorSetupActivate, ) -> Result<PostLoginTwofactorSetupActivateData>
Activate authenticator and complete required setup
POST /login/twofactor/setup/activate
Verifies a code from the secret initialized through POST /login/twofactor/setup in the same pending login session. The session identifies the person. On success, blacklists the code, enables two-factor authentication, completes browser login using the original rememberMe choice, and clears the pending session. The response includes a navigation target from that session. Invalid/reused codes, missing secret or missing setup session return 400. Activation is saved before browser login finishes, so a later failure can leave two-factor authentication enabled. This endpoint is not an idempotent status-setting operation; after success the pending session is gone. Shares the login rate limit.
§Example
let body = models::TwoFactorSetupActivate {
code: "012345".into(),
..Default::default()
};
let setup = client.login().two_factor().setup().activate(&body)?;
println!("{}", setup.redirect_to);Sourcepub fn create(&self) -> Result<TwoFactorSetupSecret>
pub fn create(&self) -> Result<TwoFactorSetupSecret>
Initialize required authenticator setup
POST /login/twofactor/setup
Starts authenticator enrollment for the person in a pending twoFactorSetup login session. Use the same cookies as the password step. Creates and stores a new secret and sets the enabled flag to false. Returns the secret and its QR-code image as a data URI. Repeating this request replaces the previous secret and invalidates its QR code, so do not use it as a read-only setup-status request. Submit a code generated from this secret to POST /login/twofactor/setup/activate. A missing or unsuitable pending session returns 400. Shares the login rate limit.
§Example
let result = client.login().two_factor().setup().create()?;
println!("{}", result.qrcode);