[aur-dev] [PATCH 1/3] Allow for resetting the SSH public key
Use NULL instead of an empty string if the SSH public key field is left empty. Additionally, do not check for duplicate keys in that case. Fixes FS#45109. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org> --- web/lib/acctfuncs.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/lib/acctfuncs.inc.php b/web/lib/acctfuncs.inc.php index 20ac081..993cd34 100644 --- a/web/lib/acctfuncs.inc.php +++ b/web/lib/acctfuncs.inc.php @@ -203,7 +203,7 @@ function process_account_form($TYPE,$A,$U="",$T="",$S="",$E="",$P="",$C="", "<strong>", htmlspecialchars($E,ENT_QUOTES), "</strong>"); } } - if (!$error) { + if (!$error && !empty($PK)) { /* * Check whether the SSH public key is available. * TODO: Fix race condition. @@ -247,7 +247,7 @@ function process_account_form($TYPE,$A,$U="",$T="",$S="",$E="",$P="",$C="", $L = $dbh->quote($L); $I = $dbh->quote($I); $K = $dbh->quote(str_replace(" ", "", $K)); - $PK = $dbh->quote($PK); + $PK = empty($PK) ? "NULL" : $dbh->quote($PK); $q = "INSERT INTO Users (AccountTypeID, Suspended, "; $q.= "InactivityTS, Username, Email, Passwd, Salt, "; $q.= "RealName, LangPreference, IRCNick, PGPKey, "; -- 2.4.1
Also, reorder the fields such that optional fields come last. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org> --- web/html/css/aurweb.css | 4 ++++ web/template/account_edit_form.php | 19 ++++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/web/html/css/aurweb.css b/web/html/css/aurweb.css index 79acce4..c86c1da 100644 --- a/web/html/css/aurweb.css +++ b/web/html/css/aurweb.css @@ -77,3 +77,7 @@ .comment-deleted { color: #999; } + +legend { + padding: 1em 0; +} diff --git a/web/template/account_edit_form.php b/web/template/account_edit_form.php index 110fbb5..415c086 100644 --- a/web/template/account_edit_form.php +++ b/web/template/account_edit_form.php @@ -97,13 +97,6 @@ <input type="text" size="30" maxlength="50" name="K" id="id_pgp" value="<?= html_format_pgp_fingerprint($K) ?>" /> </p> - <?php if ($A == "UpdateAccount"): ?> - <p> - <label for="id_ssh"><?= __("SSH Public Key") ?>:</label> - <textarea name="PK" id="id_ssh" rows="5" cols="30"><?= htmlspecialchars($PK) ?></textarea> - </p> - <?php endif; ?> - <p> <label for="id_language"><?= __("Language") ?>:</label> <select name="L" id="id_language"> @@ -119,7 +112,19 @@ ?> </select> </p> + </fieldset> + + <?php if ($A == "UpdateAccount"): ?> + <fieldset> + <legend><?= __("The following information is only required if you want to submit packages to the Arch User Repository.") ?></legend> + <p> + <label for="id_ssh"><?= __("SSH Public Key") ?>:</label> + <textarea name="PK" id="id_ssh" rows="5" cols="30"><?= htmlspecialchars($PK) ?></textarea> + </p> + </fieldset> + <?php endif; ?> + <fieldset> <p> <label></label> <?php if ($A == "UpdateAccount"): ?> -- 2.4.1
Now that we have a short explanation on how we use the SSH public key, we can show that field on the registration page. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org> --- web/html/account.php | 3 ++- web/template/account_edit_form.php | 2 -- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/web/html/account.php b/web/html/account.php index a4c630e..cb33c4e 100644 --- a/web/html/account.php +++ b/web/html/account.php @@ -124,7 +124,8 @@ if (isset($_COOKIE["AURSID"])) { process_account_form("new", "NewAccount", in_request("U"), 1, 0, in_request("E"), '', '', in_request("R"), in_request("L"), - in_request("I"), in_request("K")); + in_request("I"), in_request("K"), + in_request("PK")); } else { # display the account request form diff --git a/web/template/account_edit_form.php b/web/template/account_edit_form.php index 415c086..f988714 100644 --- a/web/template/account_edit_form.php +++ b/web/template/account_edit_form.php @@ -114,7 +114,6 @@ </p> </fieldset> - <?php if ($A == "UpdateAccount"): ?> <fieldset> <legend><?= __("The following information is only required if you want to submit packages to the Arch User Repository.") ?></legend> <p> @@ -122,7 +121,6 @@ <textarea name="PK" id="id_ssh" rows="5" cols="30"><?= htmlspecialchars($PK) ?></textarea> </p> </fieldset> - <?php endif; ?> <fieldset> <p> -- 2.4.1
participants (1)
-
Lukas Fleischer