Cli: add prompt_for_password() helper method
This commit is contained in:
parent
f79be675fb
commit
d546bebe49
7 changed files with 97 additions and 51 deletions
File diff suppressed because one or more lines are too long
Binary file not shown.
|
@ -1,7 +1,7 @@
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: \n"
|
"Project-Id-Version: \n"
|
||||||
"POT-Creation-Date: 2023-02-28 01:28+0100\n"
|
"POT-Creation-Date: 2023-02-28 01:45+0100\n"
|
||||||
"PO-Revision-Date: \n"
|
"PO-Revision-Date: \n"
|
||||||
"Last-Translator: Benjamin Renard <brenard@zionetrix.net>\n"
|
"Last-Translator: Benjamin Renard <brenard@zionetrix.net>\n"
|
||||||
"Language-Team: \n"
|
"Language-Team: \n"
|
||||||
|
@ -118,6 +118,16 @@ msgstr ""
|
||||||
"Port d'écoute spécifié invalide. Il doit s'agir d'un entier positif entre 1 "
|
"Port d'écoute spécifié invalide. Il doit s'agir d'un entier positif entre 1 "
|
||||||
"et 65535."
|
"et 65535."
|
||||||
|
|
||||||
|
#: Cli.php:354
|
||||||
|
msgid "Can't invoke bash. Can't ask password prompt."
|
||||||
|
msgstr ""
|
||||||
|
"Impossible d'utiliser bash. Impossible de demander à l'utilisateur de saisir "
|
||||||
|
"un mot de passe."
|
||||||
|
|
||||||
|
#: Cli.php:357
|
||||||
|
msgid "Please enter password:"
|
||||||
|
msgstr "Merci de saisir le mot de passe :"
|
||||||
|
|
||||||
#: Db.php:74
|
#: Db.php:74
|
||||||
msgid "Unable to connect to the database."
|
msgid "Unable to connect to the database."
|
||||||
msgstr "Impossible de se connecter à la base de données."
|
msgstr "Impossible de se connecter à la base de données."
|
||||||
|
@ -130,11 +140,11 @@ msgstr "Nom d'utilisateur ou mot de passe invalide."
|
||||||
msgid "Sign in"
|
msgid "Sign in"
|
||||||
msgstr "Connexion"
|
msgstr "Connexion"
|
||||||
|
|
||||||
#: Auth/Http.php:34 Url.php:176
|
#: Auth/Http.php:34 Url.php:177
|
||||||
msgid "Authentication required"
|
msgid "Authentication required"
|
||||||
msgstr "Authentification requise"
|
msgstr "Authentification requise"
|
||||||
|
|
||||||
#: Auth/Http.php:115 Auth/Http.php:118 Url.php:180
|
#: Auth/Http.php:115 Auth/Http.php:118 Url.php:181
|
||||||
msgid "Access denied"
|
msgid "Access denied"
|
||||||
msgstr "Accès interdit"
|
msgstr "Accès interdit"
|
||||||
|
|
||||||
|
@ -182,19 +192,19 @@ msgstr "Aucun template spécifié."
|
||||||
msgid "An error occurred while displaying this page."
|
msgid "An error occurred while displaying this page."
|
||||||
msgstr "Une erreur est survenue en affichant cette page."
|
msgstr "Une erreur est survenue en affichant cette page."
|
||||||
|
|
||||||
#: Url.php:172
|
#: Url.php:173
|
||||||
msgid "Bad request"
|
msgid "Bad request"
|
||||||
msgstr "Mauvaise requête"
|
msgstr "Mauvaise requête"
|
||||||
|
|
||||||
#: Url.php:173
|
#: Url.php:174
|
||||||
msgid "Invalid request."
|
msgid "Invalid request."
|
||||||
msgstr "Requête invalide."
|
msgstr "Requête invalide."
|
||||||
|
|
||||||
#: Url.php:177
|
#: Url.php:178
|
||||||
msgid "You have to be authenticated to access to this page."
|
msgid "You have to be authenticated to access to this page."
|
||||||
msgstr "Vous devez être authentifié pour accéder à cette page."
|
msgstr "Vous devez être authentifié pour accéder à cette page."
|
||||||
|
|
||||||
#: Url.php:181
|
#: Url.php:182
|
||||||
msgid ""
|
msgid ""
|
||||||
"You do not have access to this application. If you think this is an error, "
|
"You do not have access to this application. If you think this is an error, "
|
||||||
"please contact support."
|
"please contact support."
|
||||||
|
@ -202,25 +212,25 @@ msgstr ""
|
||||||
"Vous n'avez pas accès à cette application. Si vous pensez qu'il s'agit d'une "
|
"Vous n'avez pas accès à cette application. Si vous pensez qu'il s'agit d'une "
|
||||||
"erreur, merci de prendre contact avec le support."
|
"erreur, merci de prendre contact avec le support."
|
||||||
|
|
||||||
#: Url.php:184
|
#: Url.php:185
|
||||||
msgid "Whoops ! Page not found"
|
msgid "Whoops ! Page not found"
|
||||||
msgstr "Oups ! Page introuvable"
|
msgstr "Oups ! Page introuvable"
|
||||||
|
|
||||||
#: Url.php:185
|
#: Url.php:186
|
||||||
msgid "The requested page can not be found."
|
msgid "The requested page can not be found."
|
||||||
msgstr "La page demandée est introuvable."
|
msgstr "La page demandée est introuvable."
|
||||||
|
|
||||||
#: Url.php:193
|
#: Url.php:194
|
||||||
msgid "Error"
|
msgid "Error"
|
||||||
msgstr "Erreur"
|
msgstr "Erreur"
|
||||||
|
|
||||||
#: Url.php:194
|
#: Url.php:195
|
||||||
msgid "An unknown error occurred. If problem persist, please contact support."
|
msgid "An unknown error occurred. If problem persist, please contact support."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Une erreur inconnue est survenue. Si le problème persiste, merci de prendre "
|
"Une erreur inconnue est survenue. Si le problème persiste, merci de prendre "
|
||||||
"contact avec le support."
|
"contact avec le support."
|
||||||
|
|
||||||
#: Url.php:257
|
#: Url.php:258
|
||||||
msgid ""
|
msgid ""
|
||||||
"Unable to determine the requested page. If the problem persists, please "
|
"Unable to determine the requested page. If the problem persists, please "
|
||||||
"contact support."
|
"contact support."
|
||||||
|
@ -228,7 +238,7 @@ msgstr ""
|
||||||
"Impossible de déterminer la page demandée. Si le problème persiste, merci de "
|
"Impossible de déterminer la page demandée. Si le problème persiste, merci de "
|
||||||
"prendre contact avec le support."
|
"prendre contact avec le support."
|
||||||
|
|
||||||
#: Url.php:411
|
#: Url.php:412
|
||||||
msgid ""
|
msgid ""
|
||||||
"Unable to determine the requested page (loop detected). If the problem "
|
"Unable to determine the requested page (loop detected). If the problem "
|
||||||
"persists, please contact support."
|
"persists, please contact support."
|
||||||
|
@ -236,15 +246,15 @@ msgstr ""
|
||||||
"Impossible de déterminer la page demandée (boucle détectée). Si le problème "
|
"Impossible de déterminer la page demandée (boucle détectée). Si le problème "
|
||||||
"persiste, merci de prendre contact avec le support."
|
"persiste, merci de prendre contact avec le support."
|
||||||
|
|
||||||
#: Url.php:441
|
#: Url.php:442
|
||||||
msgid "This request cannot be processed."
|
msgid "This request cannot be processed."
|
||||||
msgstr "Cette requête ne peut être traitée."
|
msgstr "Cette requête ne peut être traitée."
|
||||||
|
|
||||||
#: Url.php:451
|
#: Url.php:452
|
||||||
msgid "Authentication required but fail to authenticate you."
|
msgid "Authentication required but fail to authenticate you."
|
||||||
msgstr "Authentification requise mais impossible pour vous authentifier."
|
msgstr "Authentification requise mais impossible pour vous authentifier."
|
||||||
|
|
||||||
#: Url.php:460
|
#: Url.php:461
|
||||||
msgid "This request could not be processed correctly."
|
msgid "This request could not be processed correctly."
|
||||||
msgstr "Cette requête n'a put être traitée correctement."
|
msgstr "Cette requête n'a put être traitée correctement."
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"POT-Creation-Date: 2023-02-28 01:28+0100\n"
|
"POT-Creation-Date: 2023-02-28 01:45+0100\n"
|
||||||
"PO-Revision-Date: 2023-02-28 01:28+0100\n"
|
"PO-Revision-Date: 2023-02-28 01:45+0100\n"
|
||||||
"MIME-Version: 1.0\n"
|
"MIME-Version: 1.0\n"
|
||||||
"Content-Type: text/plain; charset=utf-8\n"
|
"Content-Type: text/plain; charset=utf-8\n"
|
||||||
"Content-Transfer-Encoding: 8bit\n"
|
"Content-Transfer-Encoding: 8bit\n"
|
|
@ -1,7 +1,7 @@
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"POT-Creation-Date: 2023-02-28 01:28+0100\n"
|
"POT-Creation-Date: 2023-02-28 01:45+0100\n"
|
||||||
"PO-Revision-Date: 2023-02-28 01:28+0100\n"
|
"PO-Revision-Date: 2023-02-28 01:45+0100\n"
|
||||||
"MIME-Version: 1.0\n"
|
"MIME-Version: 1.0\n"
|
||||||
"Content-Type: text/plain; charset=UTF-8\n"
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
"Content-Transfer-Encoding: 8bit\n"
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
@ -98,6 +98,14 @@ msgid ""
|
||||||
"65535."
|
"65535."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: Cli.php:354
|
||||||
|
msgid "Can't invoke bash. Can't ask password prompt."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: Cli.php:357
|
||||||
|
msgid "Please enter password:"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: Db.php:74
|
#: Db.php:74
|
||||||
msgid "Unable to connect to the database."
|
msgid "Unable to connect to the database."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
@ -110,11 +118,11 @@ msgstr ""
|
||||||
msgid "Sign in"
|
msgid "Sign in"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: Auth/Http.php:34 Url.php:176
|
#: Auth/Http.php:34 Url.php:177
|
||||||
msgid "Authentication required"
|
msgid "Authentication required"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: Auth/Http.php:115 Auth/Http.php:118 Url.php:180
|
#: Auth/Http.php:115 Auth/Http.php:118 Url.php:181
|
||||||
msgid "Access denied"
|
msgid "Access denied"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -156,61 +164,61 @@ msgstr ""
|
||||||
msgid "An error occurred while displaying this page."
|
msgid "An error occurred while displaying this page."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: Url.php:172
|
#: Url.php:173
|
||||||
msgid "Bad request"
|
msgid "Bad request"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: Url.php:173
|
#: Url.php:174
|
||||||
msgid "Invalid request."
|
msgid "Invalid request."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: Url.php:177
|
#: Url.php:178
|
||||||
msgid "You have to be authenticated to access to this page."
|
msgid "You have to be authenticated to access to this page."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: Url.php:181
|
#: Url.php:182
|
||||||
msgid ""
|
msgid ""
|
||||||
"You do not have access to this application. If you think this is an error, "
|
"You do not have access to this application. If you think this is an error, "
|
||||||
"please contact support."
|
"please contact support."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: Url.php:184
|
#: Url.php:185
|
||||||
msgid "Whoops ! Page not found"
|
msgid "Whoops ! Page not found"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: Url.php:185
|
#: Url.php:186
|
||||||
msgid "The requested page can not be found."
|
msgid "The requested page can not be found."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: Url.php:193
|
#: Url.php:194
|
||||||
msgid "Error"
|
msgid "Error"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: Url.php:194
|
#: Url.php:195
|
||||||
msgid "An unknown error occurred. If problem persist, please contact support."
|
msgid "An unknown error occurred. If problem persist, please contact support."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: Url.php:257
|
#: Url.php:258
|
||||||
msgid ""
|
msgid ""
|
||||||
"Unable to determine the requested page. If the problem persists, please "
|
"Unable to determine the requested page. If the problem persists, please "
|
||||||
"contact support."
|
"contact support."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: Url.php:411
|
#: Url.php:412
|
||||||
msgid ""
|
msgid ""
|
||||||
"Unable to determine the requested page (loop detected). If the problem "
|
"Unable to determine the requested page (loop detected). If the problem "
|
||||||
"persists, please contact support."
|
"persists, please contact support."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: Url.php:441
|
#: Url.php:442
|
||||||
msgid "This request cannot be processed."
|
msgid "This request cannot be processed."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: Url.php:451
|
#: Url.php:452
|
||||||
msgid "Authentication required but fail to authenticate you."
|
msgid "Authentication required but fail to authenticate you."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: Url.php:460
|
#: Url.php:461
|
||||||
msgid "This request could not be processed correctly."
|
msgid "This request could not be processed correctly."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
|
|
@ -90,6 +90,14 @@ msgid ""
|
||||||
"65535."
|
"65535."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: Cli.php:354
|
||||||
|
msgid "Can't invoke bash. Can't ask password prompt."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: Cli.php:357
|
||||||
|
msgid "Please enter password:"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: Db.php:74
|
#: Db.php:74
|
||||||
msgid "Unable to connect to the database."
|
msgid "Unable to connect to the database."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
@ -102,11 +110,11 @@ msgstr ""
|
||||||
msgid "Sign in"
|
msgid "Sign in"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: Auth/Http.php:34 Url.php:176
|
#: Auth/Http.php:34 Url.php:177
|
||||||
msgid "Authentication required"
|
msgid "Authentication required"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: Auth/Http.php:115 Auth/Http.php:118 Url.php:180
|
#: Auth/Http.php:115 Auth/Http.php:118 Url.php:181
|
||||||
msgid "Access denied"
|
msgid "Access denied"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -148,61 +156,61 @@ msgstr ""
|
||||||
msgid "An error occurred while displaying this page."
|
msgid "An error occurred while displaying this page."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: Url.php:172
|
#: Url.php:173
|
||||||
msgid "Bad request"
|
msgid "Bad request"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: Url.php:173
|
#: Url.php:174
|
||||||
msgid "Invalid request."
|
msgid "Invalid request."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: Url.php:177
|
#: Url.php:178
|
||||||
msgid "You have to be authenticated to access to this page."
|
msgid "You have to be authenticated to access to this page."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: Url.php:181
|
#: Url.php:182
|
||||||
msgid ""
|
msgid ""
|
||||||
"You do not have access to this application. If you think this is an error, "
|
"You do not have access to this application. If you think this is an error, "
|
||||||
"please contact support."
|
"please contact support."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: Url.php:184
|
#: Url.php:185
|
||||||
msgid "Whoops ! Page not found"
|
msgid "Whoops ! Page not found"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: Url.php:185
|
#: Url.php:186
|
||||||
msgid "The requested page can not be found."
|
msgid "The requested page can not be found."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: Url.php:193
|
#: Url.php:194
|
||||||
msgid "Error"
|
msgid "Error"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: Url.php:194
|
#: Url.php:195
|
||||||
msgid "An unknown error occurred. If problem persist, please contact support."
|
msgid "An unknown error occurred. If problem persist, please contact support."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: Url.php:257
|
#: Url.php:258
|
||||||
msgid ""
|
msgid ""
|
||||||
"Unable to determine the requested page. If the problem persists, please "
|
"Unable to determine the requested page. If the problem persists, please "
|
||||||
"contact support."
|
"contact support."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: Url.php:411
|
#: Url.php:412
|
||||||
msgid ""
|
msgid ""
|
||||||
"Unable to determine the requested page (loop detected). If the problem "
|
"Unable to determine the requested page (loop detected). If the problem "
|
||||||
"persists, please contact support."
|
"persists, please contact support."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: Url.php:441
|
#: Url.php:442
|
||||||
msgid "This request cannot be processed."
|
msgid "This request cannot be processed."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: Url.php:451
|
#: Url.php:452
|
||||||
msgid "Authentication required but fail to authenticate you."
|
msgid "Authentication required but fail to authenticate you."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: Url.php:460
|
#: Url.php:461
|
||||||
msgid "This request could not be processed correctly."
|
msgid "This request could not be processed correctly."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
|
20
src/Cli.php
20
src/Cli.php
|
@ -341,4 +341,24 @@ class Cli {
|
||||||
exit($exit_code);
|
exit($exit_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method to ask user to enter a password
|
||||||
|
* Note: this method use the bash binary and a fatal error will be trigger if it's not available.
|
||||||
|
* @param string|null $prompt The prompt message (optional)
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function prompt_for_password($prompt=null) {
|
||||||
|
// Check bash is available
|
||||||
|
$command = "/usr/bin/env bash -c 'echo OK'";
|
||||||
|
if (rtrim(shell_exec($command)) !== 'OK')
|
||||||
|
Log::fatal(I18n::_("Can't invoke bash. Can't ask password prompt."));
|
||||||
|
|
||||||
|
$command = "/usr/bin/env bash -c 'read -s -p \"";
|
||||||
|
$command .= addslashes($prompt?_($prompt):I18n::_("Please enter password:"));
|
||||||
|
$command .= "\" mypassword && echo \$mypassword'";
|
||||||
|
$password = rtrim(shell_exec($command));
|
||||||
|
echo "\n";
|
||||||
|
return $password;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue