pub struct LoginResource<'a> { /* private fields */ }Expand description
client.login()
Implementations§
Source§impl<'a> LoginResource<'a>
impl<'a> LoginResource<'a>
pub fn two_factor(&self) -> LoginTwoFactorResource<'a>
Sourcepub fn create(&self, body: &LoginCreate) -> Result<LoginResult>
pub fn create(&self, body: &LoginCreate) -> Result<LoginResult>
Start password-based login
POST /login
Verifies a username/email and password, using configured LDAP authentication before local credentials. The configured default-login policy is enforced. HTTP 200 may mean login succeeded or that a second step is required; inspect data.status. With totp, submit the code and personId to POST /login/totp. With twoFactorSetup, initialize and activate two-factor setup before login is completed. Preserve cookies across all steps. rememberMe controls persistent browser login. Invalid credentials and locked accounts return 400, not 401. Failed local attempts increment account counters. All login steps share the configured login rate limit.
§Example
let body = models::LoginCreate {
password: "example-password".into(),
username: "alex@example.org".into(),
..Default::default()
};
let result = client.login().create(&body)?;
println!("{:?}", result.location);Sourcepub fn token(&self, body: &LoginCredentials) -> Result<LoginTokenResult>
pub fn token(&self, body: &LoginCredentials) -> Result<LoginTokenResult>
Get or create a persistent login token
POST /login/token
Verifies username/email and password and returns the person’s existing persistent login token, creating one only if none exists. No browser login is completed by this operation. The configured default-login policy applies. Accounts with activated two-factor authentication are rejected with 400. Token retrieval is blocked during non-support simulation. The returned credential has no expiry field and remains independent of logout. Failed credential checks can increment local account error counters. This route shares the configured login rate limit with the other login steps.
§Example
let body = models::LoginCredentials {
password: "example-password".into(),
username: "alex@example.org".into(),
..Default::default()
};
let login = client.login().token(&body)?;
println!("{}", login.person_id);Sourcepub fn totp(&self, body: &LoginTotpVerify) -> Result<TwoFactorLoginResult>
pub fn totp(&self, body: &LoginTotpVerify) -> Result<TwoFactorLoginResult>
Complete login with an authenticator code
POST /login/totp
Verifies the authenticator code for the person bound to the pending password-verified session. Retain the same session cookie from POST /login; this operation does not use ordinary API authentication to select a person. On success the code is temporarily blacklisted, login is completed and the pending session is removed. A pending external-account link is completed instead when that context exists. If two-factor authentication was disabled or its secret disappeared after the password step, the legacy normal-login branch returns success without redirectTo and without completing login; clients should restart the login flow. Invalid or reused codes, missing pending session and person mismatch return 400. Shares the login rate limit.
§Example
let body = models::LoginTotpVerify {
code: "012345".into(),
person_id: 42,
..Default::default()
};
let login = client.login().totp(&body)?;
println!("{:?}", login.redirect_to);