From 4fd842f5661d1302513f94bddb269ce1462610d2 Mon Sep 17 00:00:00 2001 From: brapru Date: Mon, 24 May 2021 15:50:56 -0400 Subject: [PATCH] passwd: Retype password to confirm Previously passwd would accept the first password input by the user. It should ask the user to re-type the password to check for mismatches and prevent typos in the password. --- Userland/Utilities/passwd.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Userland/Utilities/passwd.cpp b/Userland/Utilities/passwd.cpp index 7ef5f59411..e185ed38fa 100644 --- a/Userland/Utilities/passwd.cpp +++ b/Userland/Utilities/passwd.cpp @@ -103,6 +103,17 @@ int main(int argc, char** argv) return 1; } + auto new_password_retype = Core::get_password("Retype new password: "); + if (new_password_retype.is_error()) { + warnln("{}", new_password_retype.error()); + return 1; + } + + if (new_password.value() != new_password_retype.value()) { + warnln("Sorry, passwords don't match."); + return 1; + } + target_account.set_password(new_password.value().characters()); }