Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ You can create a basic configuration in `$CONFIG_DIR/iamb/config.toml` that look
user_id = "@user:example.com"
```

If you homeserver is located on a different domain than the server part of the
If your homeserver is located on a different domain than the server part of the
`user_id` and you don't have a [`/.well-known`][well_known_entry] entry, then
you can explicitly specify the homeserver URL to use:

Expand Down
1 change: 1 addition & 0 deletions config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ default_profile = "default"

[profiles.default]
user_id = "@user:matrix.org"
password_file = "/path/to/password"
url = "https://matrix.org"

[settings]
Expand Down
1 change: 1 addition & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,7 @@ pub enum Layout {
#[derive(Clone, Deserialize)]
pub struct ProfileConfig {
pub user_id: OwnedUserId,
pub password_file: Option<PathBuf>,
pub url: Option<Url>,
pub settings: Option<Tunables>,
pub dirs: Option<Directories>,
Expand Down
11 changes: 11 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,17 @@ async fn login(worker: &Requester, settings: &ApplicationSettings) -> IambResult
return Ok(());
}

if let Some(ref password_file) = settings.profile.password_file {
if let Err(e) = std::fs::read_to_string(password_file)
.map(|password| worker.login(LoginStyle::Password(password)))
{
println!("Failed to log in using password file {password_file:?}: {e}");
println!("Continuing on to interactive login");
} else {
return Ok(());
}
}

loop {
let login_style =
match read_response("Please select login type: [p]assword / [s]ingle sign on")
Expand Down
1 change: 1 addition & 0 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ pub fn mock_settings() -> ApplicationSettings {
profile_name: "test".into(),
profile: ProfileConfig {
user_id: user_id!("@user:example.com").to_owned(),
password_file: None,
url: None,
settings: None,
dirs: None,
Expand Down