diff options
author | Sergey Ponomarev <stokito@gmail.com> | 2023-12-17 12:55:29 +0200 |
---|---|---|
committer | Paul Donald <itsascambutmailmeanyway@gmail.com> | 2023-12-27 20:24:25 +0000 |
commit | 3933633dd0de84b1c13af5d8f62b6b2431bf1ca7 (patch) | |
tree | fcccd9edbc480442441d03f69d1ed60b422385f6 /applications/luci-app-sshtunnel/htdocs/luci-static | |
parent | b8638323c4fd2d5eb47550f78e581295e345dacc (diff) |
luci-app-sshtunnel: generate a new key
Make the Generate a new key as a separate section and move to bottom.
Extend the key name pattern to be an email address so allow symbols @ - +.
Force the id_ prefix for key names.
Signed-off-by: Sergey Ponomarev <stokito@gmail.com>
Diffstat (limited to 'applications/luci-app-sshtunnel/htdocs/luci-static')
-rw-r--r-- | applications/luci-app-sshtunnel/htdocs/luci-static/resources/view/sshtunnel/ssh_keys.js | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/applications/luci-app-sshtunnel/htdocs/luci-static/resources/view/sshtunnel/ssh_keys.js b/applications/luci-app-sshtunnel/htdocs/luci-static/resources/view/sshtunnel/ssh_keys.js index 6c83454b0d..4001404aad 100644 --- a/applications/luci-app-sshtunnel/htdocs/luci-static/resources/view/sshtunnel/ssh_keys.js +++ b/applications/luci-app-sshtunnel/htdocs/luci-static/resources/view/sshtunnel/ssh_keys.js @@ -67,16 +67,17 @@ function _renderSshKeys(sshKeys) { cbi_update_table(table, rows, null); var keyGenBtn = E('div', {}, [ + E('h4', _('Generate a new key')), E('form', { 'submit': _handleKeyGenSubmit, }, [ - E('label', {}, _('Generate a new key') + ': '), + E('label', {}, _('Name') + ': '), E('span', {'class': 'control-group'}, [ E('input', { 'type': 'text', 'name': 'keyName', 'value': 'id_ed25519', - 'pattern': '^[a-zA-Z][a-zA-Z0-9_\.]+', + 'pattern': '^[a-zA-Z][a-zA-Z0-9_.@\\-+]+', 'required': 'required', 'maxsize': '35', 'autocomplete': 'off', @@ -97,13 +98,14 @@ function _renderSshKeys(sshKeys) { _('In LuCI you can do that with <a %s>System / Administration / SSH-Keys</a>') .format('href="/cgi-bin/luci/admin/system/admin/sshkeys"') ), - keyGenBtn, table + table, keyGenBtn, ]); } function _handleKeyGenSubmit(event) { event.preventDefault(); var keyName = document.querySelector('input[name="keyName"]').value; + keyName = keyName.startsWith('id_') ? keyName : 'id_' + keyName; if (allSshKeys[keyName]) { document.body.scrollTop = document.documentElement.scrollTop = 0; ui.addNotification(null, E('p', _('A key with that name already exists.'), 'error')); |