public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH manager] fix #4758: ui: lxc wizard: allow multiple ssh keys
Date: Mon,  3 Jul 2023 15:37:11 +0200	[thread overview]
Message-ID: <20230703133711.3268237-1-d.csapak@proxmox.com> (raw)

by converting the textfield into a textarea and validate the value
line wise (if there is more than one line)

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 www/manager6/lxc/CreateWizard.js | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/www/manager6/lxc/CreateWizard.js b/www/manager6/lxc/CreateWizard.js
index 0b82cc1c..e74b0b5c 100644
--- a/www/manager6/lxc/CreateWizard.js
+++ b/www/manager6/lxc/CreateWizard.js
@@ -120,17 +120,29 @@ Ext.define('PVE.lxc.CreateWizard', {
 		    },
 		},
 		{
-		    xtype: 'proxmoxtextfield',
+		    xtype: 'textarea',
 		    name: 'ssh-public-keys',
 		    value: '',
-		    fieldLabel: gettext('SSH public key'),
+		    fieldLabel: gettext('SSH public key(s)'),
 		    allowBlank: true,
 		    validator: function(value) {
 			let pwfield = this.up().down('field[name=password]');
 			if (value.length) {
-			    let key = PVE.Parser.parseSSHKey(value);
-			    if (!key) {
-				return "Failed to recognize ssh key";
+			    if (value.indexOf('\n') !== -1) {
+				let err;
+				value.split('\n').forEach((key) => {
+				    if (key !== '' && !PVE.Parser.parseSSHKey(key)) {
+					err = "Failed to recognize ssh key";
+				    }
+				});
+				if (err) {
+				    return err;
+				}
+			    } else {
+				let key = PVE.Parser.parseSSHKey(value);
+				if (!key) {
+				    return "Failed to recognize ssh key";
+				}
 			    }
 			    pwfield.allowBlank = true;
 			} else {
@@ -166,7 +178,7 @@ Ext.define('PVE.lxc.CreateWizard', {
 		    listeners: {
 			change: function(btn, e, value) {
 			    e = e.event;
-			    let field = this.up().down('proxmoxtextfield[name=ssh-public-keys]');
+			    let field = this.up().down('textarea[name=ssh-public-keys]');
 			    PVE.Utils.loadSSHKeyFromFile(e.target.files[0], v => field.setValue(v));
 			    btn.reset();
 			},
-- 
2.30.2





             reply	other threads:[~2023-07-03 13:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-03 13:37 Dominik Csapak [this message]
2023-07-03 14:24 ` Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230703133711.3268237-1-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal