MCPcopy Index your code
hub / github.com/endbasic/endbasic / read_password

Method read_password

client/src/cmds.rs:482–501  ·  view source on GitHub ↗

Tries to get a password from the user until it is valid.

(console: &mut dyn Console)

Source from the content-addressed store, hash-verified

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)]

Callers

nothing calls this directly

Calls 3

read_line_secureFunction · 0.85
printMethod · 0.45

Tested by

no test coverage detected