|
| 1 | +'use strict'; |
| 2 | +'require baseclass'; |
| 3 | +'require view'; |
| 4 | +'require form'; |
| 5 | + |
| 6 | +return baseclass.extend({ |
| 7 | + class: 'password', |
| 8 | + class_i18n: _('Password'), |
| 9 | + |
| 10 | + type: 'policy', |
| 11 | + type_i18n: _('Policy'), |
| 12 | + |
| 13 | + name: 'Password Policy', |
| 14 | + id: '51af4ae847774aac863d4c94a9ba6d58', |
| 15 | + title: _('Password Policy'), |
| 16 | + description: _('Here you can enforce a password policy sytem wide'), |
| 17 | + |
| 18 | + addFormOptions(s) { |
| 19 | + let o; |
| 20 | + |
| 21 | + o = s.option(form.Flag, 'enabled', _('Enable password policy')); |
| 22 | + o.default = o.disabled; |
| 23 | + o.remempty = false; |
| 24 | + |
| 25 | + o = s.option(form.Value, 'pw_length', _('Minimum password length')); |
| 26 | + o.optional = false; |
| 27 | + o.datatype = 'uinteger'; |
| 28 | + o.placeholder = 8; |
| 29 | + |
| 30 | + o = s.option(form.Flag, 'digits', _('Digits')); |
| 31 | + o.default = false; |
| 32 | + |
| 33 | + o = s.option(form.Flag, 'uc_lc', _('Upper / lower case characters')); |
| 34 | + o.default = false; |
| 35 | + |
| 36 | + o = s.option(form.Flag, 'special_characters', _('Special characters')); |
| 37 | + o.default = false; |
| 38 | + |
| 39 | + }, |
| 40 | + |
| 41 | + configSummary(section) { |
| 42 | + if (section.enabled != '1') |
| 43 | + return null; |
| 44 | + |
| 45 | + var summary = []; |
| 46 | + |
| 47 | + if (section.pw_length) |
| 48 | + summary.push(_('min. password length')); |
| 49 | + |
| 50 | + if (section.digits) |
| 51 | + summary.push(_('digit occurence')); |
| 52 | + |
| 53 | + if (section.uc_lc) |
| 54 | + summary.push(_('uppercase/lowercase occurence')); |
| 55 | + |
| 56 | + if (section.special_characters) |
| 57 | + summary.push(_('special characters occurence')); |
| 58 | + |
| 59 | + return summary.length ? summary.join (', ') : _('Password Policy enabled'); |
| 60 | + } |
| 61 | +}); |
0 commit comments