Tries to get a password from the user until it is valid.
(console: &mut dyn Console)
| 480 | |
| 481 | /// Tries to get a password from the user until it is valid. |
| 482 | async fn read_password(console: &mut dyn Console) -> io::Result<String> { |
| 483 | loop { |
| 484 | let password = read_line_secure(console, "Password: ").await?; |
| 485 | match validate_password_complexity(&password) { |
| 486 | Ok(()) => (), |
| 487 | Err(e) => { |
| 488 | console.print(&format!("Invalid password: {}; try again.", e))?; |
| 489 | continue; |
| 490 | } |
| 491 | } |
| 492 | |
| 493 | let second_password = read_line_secure(console, "Retype password: ").await?; |
| 494 | if second_password != password { |
| 495 | console.print("Passwords do not match; try again.")?; |
| 496 | continue; |
| 497 | } |
| 498 | |
| 499 | return Ok(password); |
| 500 | } |
| 501 | } |
| 502 | } |
| 503 | |
| 504 | #[async_trait(?Send)] |
nothing calls this directly
no test coverage detected