diff options
author | Kjetil Orbekk <kjetil.orbekk@gmail.com> | 2017-06-17 22:31:27 -0400 |
---|---|---|
committer | Kjetil Orbekk <kjetil.orbekk@gmail.com> | 2017-06-17 22:31:27 -0400 |
commit | 76b90acb735d3ed2b3052abc1d2403287af83619 (patch) | |
tree | 857de2ebee3d2b6ea802aa1ef249ea34bb0e0908 /src/bin | |
parent | 1e5f237c20310cbf6ace17b6a7b05298429aca46 (diff) |
rustfmt: Reformatted all the code.
Diffstat (limited to 'src/bin')
-rw-r--r-- | src/bin/crypto.rs | 4 | ||||
-rw-r--r-- | src/bin/main.rs | 20 |
2 files changed, 11 insertions, 13 deletions
diff --git a/src/bin/crypto.rs b/src/bin/crypto.rs index 5cc8549..775ea07 100644 --- a/src/bin/crypto.rs +++ b/src/bin/crypto.rs @@ -6,9 +6,7 @@ use crypto::bcrypt_pbkdf::bcrypt_pbkdf; pub fn encode(pw: &str) -> Vec<u8> { let salt = "hello"; let mut out = vec!(0; 32); - let encrypted = bcrypt_pbkdf( - pw.as_bytes(), salt.as_bytes(), - 10, &mut out); + let encrypted = bcrypt_pbkdf(pw.as_bytes(), salt.as_bytes(), 10, &mut out); out } diff --git a/src/bin/main.rs b/src/bin/main.rs index ed9e179..245416c 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -21,12 +21,11 @@ fn create_user_prompt() -> Option<(String, String)> { let mut user = String::new(); io::stdin().read_line(&mut user).unwrap(); let password = rpassword::prompt_password_stdout("Password: ").unwrap(); - let confirmation = - rpassword::prompt_password_stdout("Repeat password: ").unwrap(); + let confirmation = rpassword::prompt_password_stdout("Repeat password: ").unwrap(); if password != confirmation { error!("Passwords don't match"); - return None + return None; } Some((user.trim().to_string(), password)) } @@ -35,9 +34,7 @@ fn create_admin_user(conn: &rusqlite::Connection) { info!("Create admin user"); if let Some((user, password)) = create_user_prompt() { let enc = auth::encode("test_salt", password.as_str()); - systemhttp::db::insert_user( - &conn, user.as_str(), - &enc).expect("create user"); + systemhttp::db::insert_user(&conn, user.as_str(), &enc).expect("create user"); } } @@ -67,8 +64,11 @@ fn main() { .about("Add an admin user to the db")) .get_matches(); - let port = matches.value_of("port").unwrap_or("8080") - .parse::<u16>().expect("port number"); + let port = matches + .value_of("port") + .unwrap_or("8080") + .parse::<u16>() + .expect("port number"); let db_file = matches.value_of("db_file").unwrap(); @@ -79,12 +79,12 @@ fn main() { let mut context = systemhttp::server::Context { base_url: "http://localhost:8080".to_string(), - conn: conn + conn: conn, }; match matches.subcommand_name() { Some("serve") => serve(context, port), Some("create_admin_user") => create_admin_user(&context.conn), - x => panic!("Don't know about subcommand: {:?}", x) + x => panic!("Don't know about subcommand: {:?}", x), } } |