Function goose_eggs::drupal::log_in [−][src]
pub async fn log_in(
user: &GooseUser,
login: Option<&Login<'_>>
) -> Result<String, GooseTaskError>
Expand description
Log into a Drupal website.
The reference to a GooseUser object is from a Goose task 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}; task!(login).set_on_start(); async fn login(user: &GooseUser) -> GooseTaskResult { // By default log in with `foo`:`bar`. let _html = log_in(&user, Login::username_password("foo", "bar").as_ref()).await?; Ok(()) }