fixes #503 - TOTP prompt no longer drops a newline (#515)

* fixes #503

* Adding comment for future archeologists. Hello, future-people!
This commit is contained in:
James Hodgkinson 2021-06-30 16:56:31 +10:00 committed by GitHub
parent 554ff3bb1b
commit 93d5c5434d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -6,7 +6,7 @@ use libc::umask;
use std::collections::BTreeMap;
use std::fs::{create_dir, File};
use std::io::ErrorKind;
use std::io::{self, BufReader, BufWriter};
use std::io::{self, BufReader, BufWriter, Write};
use std::path::PathBuf;
use webauthn_authenticator_rs::{u2fhid::U2FHid, RequestChallengeResponse, WebauthnAuthenticator};
@ -144,7 +144,9 @@ impl LoginOpt {
fn do_totp(&self, client: &mut KanidmClient) -> Result<AuthResponse, ClientError> {
let totp = loop {
println!("Enter TOTP: ");
print!("Enter TOTP: ");
// We flush stdout so it'll write the buffer to screen, continuing operation. Without it, the application halts.
io::stdout().flush().unwrap();
let mut buffer = String::new();
if let Err(e) = io::stdin().read_line(&mut buffer) {
eprintln!("Failed to read from stdin -> {:?}", e);