Function goose_eggs::drupal::log_in
source · [−]pub async fn log_in(
user: &mut GooseUser,
login: &Login<'_>
) -> Result<String, TransactionError>
Expand description
Log into a Drupal website.
The reference to a GooseUser object is from a transaction function. The optional
pointer to a Login
object can be created to override the username, password,
login url, or expected page title after log in.
If no default username is set in the Login
object, the function will default to
a username of username
which can be overridden by the GOOSE_USER
environment variable.
If no default password is set in the Login
object, the function will default to
a password of password
which can be overridden by the GOOSE_PASS
environment variable.
If no default url is set in the Login
object, the function will default to a url
of /user/login
. If no default title is set in the Login
object, the function
will verify that the title includes the username after login.
Example
use goose::prelude::*;
use goose_eggs::drupal::{log_in, Login};
transaction!(login).set_on_start();
async fn login(user: &mut GooseUser) -> TransactionResult {
// By default log in with `foo`:`bar`.
let login = Login::builder()
.username("foo")
.password("bar")
.build();
let _html = log_in(user, &login).await?;
Ok(())
}