Commit 1864040c authored by Romain Reuillon's avatar Romain Reuillon
Browse files

[Console] fix: set password on command line

parent c2055707
Pipeline #1227 passed with stages
in 46 minutes and 11 seconds
......@@ -60,6 +60,12 @@ object Console extends JavaLogger {
Preference.passwordIsCorrect(cypher, preference)
}
def chosePassword(password: String)(implicit preference: Preference) =
if (!Preference.passwordChosen(preference)) {
val cypher = Cypher(password)
Preference.setPasswordTest(preference, cypher)
}
@tailrec def initPassword(implicit preference: Preference): String =
if (Preference.passwordChosen(preference) && Preference.passwordIsCorrect(Cypher(""), preference)) ""
else if (Preference.passwordChosen(preference)) {
......
......@@ -231,6 +231,8 @@ object Application extends JavaLogger {
case None Console.initPassword
}
Console.chosePassword(passwordString)
if (!Console.testPassword(passwordString)) {
println("Password is incorrect")
Console.ExitCodes.incorrectPassword
......@@ -251,6 +253,8 @@ object Application extends JavaLogger {
case None Console.initPassword
}
Console.chosePassword(passwordString)
if (!Console.testPassword(passwordString)) {
println("Password is incorrect")
Console.ExitCodes.incorrectPassword
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment