77'require uci' ;
88'require form' ;
99'require tools.widgets as widgets' ;
10+ 'require tools.password as pwtool' ;
1011
1112const aclList = { } ;
1213
@@ -17,6 +18,28 @@ const callSetPassword = rpc.declare({
1718 expect : { result : 1 }
1819} ) ;
1920
21+ function checkPassword ( value ) {
22+ const uuid = '51af4ae847774aac863d4c94a9ba6d58' ;
23+ const pw_length = uci . get ( 'luci_plugins' , uuid , 'pw_length' ) ;
24+ const pw_digits = uci . get ( 'luci_plugins' , uuid , 'digits' ) ;
25+ const pw_ul = uci . get ( 'luci_plugins' , uuid , 'uc_lc' ) ;
26+ const special = uci . get ( 'luci_plugins' , uuid , 'special_characters' ) ;
27+
28+ if ( pw_length && ! pwtool . checkLength ( value , pw_length ) )
29+ return _ ( 'Policy: min. length of %s characters' ) . format ( pw_length ) ;
30+
31+ if ( pw_digits && ! pwtool . checkDigits ( value ) )
32+ return _ ( 'Policy: contain digits' ) ;
33+
34+ if ( pw_ul && ! pwtool . checkUpperLower ( value ) )
35+ return _ ( 'Policy: contain uppercase/lowercase' ) ;
36+
37+ if ( special && ! pwtool . checkSpecialChars ( value ) )
38+ return _ ( 'Policy: contain special characters' ) ;
39+
40+ return true ;
41+ }
42+
2043function globListToRegExp ( section_id , option ) {
2144 const list = L . toArray ( uci . get ( 'rpcd' , section_id , option ) ) ;
2245 const positivePatterns = [ ] ;
@@ -170,7 +193,9 @@ return view.extend({
170193 return L . resolveDefault ( fs . list ( '/usr/share/rpcd/acl.d' ) , [ ] ) . then ( function ( entries ) {
171194 const tasks = [
172195 L . resolveDefault ( fs . stat ( '/usr/sbin/uhttpd' ) , null ) ,
173- fs . lines ( '/etc/passwd' )
196+ fs . lines ( '/etc/passwd' ) ,
197+ uci . load ( 'rpcd' ) ,
198+ uci . load ( 'luci_plugins' )
174199 ] ;
175200
176201 for ( let e of entries )
@@ -181,7 +206,7 @@ return view.extend({
181206 } ) ;
182207 } ,
183208
184- render ( [ has_uhttpd , passwd , ...acls ] ) {
209+ render ( [ has_uhttpd , passwd , uci_rpcd , plugins , ...acls ] ) {
185210 ui . addNotification ( null , E ( 'p' , [
186211 _ ( 'The LuCI ACL management is in an experimental stage! It does not yet work reliably with all applications' )
187212 ] ) , 'warning' ) ;
@@ -275,7 +300,7 @@ return view.extend({
275300 return _ ( 'Cannot encrypt plaintext password since uhttpd is not installed.' ) ;
276301 }
277302
278- return true ;
303+ return checkPassword ( value ) ;
279304 } ;
280305 o . write = function ( section_id , value ) {
281306 const variant = this . map . lookupOption ( '_variant' , section_id ) [ 0 ] ;
0 commit comments