limit key length to 12

This commit is contained in:
Roland Gruber 2018-12-29 20:06:13 +01:00
parent f0086e725b
commit a206e9fefe
3 changed files with 24 additions and 3 deletions

View File

@ -1354,9 +1354,10 @@ abstract class baseModule {
* @param array $autoCompleteValues values for auto-completion * @param array $autoCompleteValues values for auto-completion
* @param integer $fieldSize field size * @param integer $fieldSize field size
* @param array $htmlIDs reference to array where to add the generated HTML IDs of the input fields * @param array $htmlIDs reference to array where to add the generated HTML IDs of the input fields
* @param string $cssClasses additional CSS classes of input fields
*/ */
protected function addMultiValueInputTextField(&$container, $attrName, $label, $required = false, $length = null, $isTextArea = false, protected function addMultiValueInputTextField(&$container, $attrName, $label, $required = false, $length = null, $isTextArea = false,
$autoCompleteValues = null, $fieldSize = null, &$htmlIDs = null) { $autoCompleteValues = null, $fieldSize = null, &$htmlIDs = null, $cssClasses = '') {
$values = array(); $values = array();
if (isset($this->attributes[$attrName][0])) { if (isset($this->attributes[$attrName][0])) {
$values = $this->attributes[$attrName]; $values = $this->attributes[$attrName];
@ -1376,6 +1377,9 @@ abstract class baseModule {
for ($i = 0; $i < sizeof($values); $i++) { for ($i = 0; $i < sizeof($values); $i++) {
if (!$isTextArea) { if (!$isTextArea) {
$input = new htmlInputField($attrName . '_' . $i, $values[$i]); $input = new htmlInputField($attrName . '_' . $i, $values[$i]);
if (!empty($cssClasses)) {
$input->setCSSClasses(array($cssClasses));
}
if (!empty($length)) { if (!empty($length)) {
$input->setFieldMaxLength($length); $input->setFieldMaxLength($length);
} }
@ -1392,7 +1396,11 @@ abstract class baseModule {
if ($length != null) { if ($length != null) {
$cols = $length; $cols = $length;
} }
$subContainer->addElement(new htmlInputTextarea($attrName . '_' . $i, $values[$i], $cols, 3)); $textArea = new htmlInputTextarea($attrName . '_' . $i, $values[$i], $cols, 3);
if (!empty($cssClasses)) {
$textArea->setCSSClasses(array($cssClasses));
}
$subContainer->addElement($textArea);
} }
if (!empty($htmlIDs)) { if (!empty($htmlIDs)) {
$htmlIDs[] = $attrName . '_' . $i; $htmlIDs[] = $attrName . '_' . $i;

View File

@ -145,7 +145,8 @@ class yubiKeyUser extends baseModule {
return $return; return $return;
} }
if (empty($objectClass) || in_array($objectClass, $this->attributes['objectClass'])) { if (empty($objectClass) || in_array($objectClass, $this->attributes['objectClass'])) {
$this->addMultiValueInputTextField($return, $attributeName, _('YubiKey ids'), false, '256', false, null, '50'); $htmlIds = array();
$this->addMultiValueInputTextField($return, $attributeName, _('YubiKey ids'), false, '12', false, null, null, $htmlIds, 'lam-prevent-enter');
if (!empty($objectClass)) { if (!empty($objectClass)) {
$return->addElement(new htmlSpacer(null, '30px'), true); $return->addElement(new htmlSpacer(null, '30px'), true);

View File

@ -1100,6 +1100,17 @@ window.lam.html.activateLightboxes = function() {
}); });
}; };
/**
* Prevents enter key on input fields with class "lam-prevent-enter".
*/
window.lam.html.preventEnter = function() {
jQuery('.lam-prevent-enter').keypress(function (event) {
if (event.keyCode === 10 || event.keyCode === 13) {
event.preventDefault();
}
});
}
window.lam.selfservice = window.lam.selfservice || {}; window.lam.selfservice = window.lam.selfservice || {};
/** /**
@ -1161,4 +1172,5 @@ jQuery(document).ready(function() {
window.lam.tools.setInitialFocus(); window.lam.tools.setInitialFocus();
window.lam.tools.schema.select(); window.lam.tools.schema.select();
window.lam.html.activateLightboxes(); window.lam.html.activateLightboxes();
window.lam.html.preventEnter();
}); });