Skip to content

Commit 1cc2779

Browse files
committed
make possible to use "Basic" authecation in chat-demo
1 parent 2de36a4 commit 1cc2779

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

examples/chat-demo/src/main.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
3737
let sync_url = env::args()
3838
.nth(2)
3939
.unwrap_or_else(|| "ws://192.168.1.32:4984/demo/".to_string());
40-
let token: Option<String> = env::args().nth(3);
4140

42-
let auth = if let Some(token) = token {
43-
ReplicatorAuthentication::SessionToken(token)
44-
} else {
45-
ReplicatorAuthentication::None
41+
let auth = match (env::args().nth(3), env::args().nth(4)) {
42+
(None, None) => ReplicatorAuthentication::None,
43+
(None, Some(_)) => unreachable!(),
44+
(Some(token), None) => ReplicatorAuthentication::SessionToken(token),
45+
(Some(username), Some(password)) => ReplicatorAuthentication::Basic { username, password },
4646
};
4747

4848
let (db_thread, db_exec) = run_db_thread(db_path, sync_url, auth);

0 commit comments

Comments
 (0)