@@ -130,19 +130,21 @@ async function checkPassword(ev, type) {
130130 console .log (' emit ' + newPassword .value )
131131 // avant d accepter on cherche dans l api de pwned
132132 try {
133- const numPwns = await pwnedPassword (newP);
133+ if (props .checkPwned === true ){
134+ const numPwns = await pwnedPassword (newP);
134135
135- if (numPwns > 0 ){
136- iconIsPwnedOK (false )
137- $q .notify ({
138- message: ' <text-weight-medium>Ce mot de passe est déjà apparu lors d\' une violation de données. Vous ne pouvez pas l\' utiliser</text-weight-medium>' ,
139- })
140- emit (' update:modelValue' , ' ' )
141- return
142- }else {
143- iconIsPwnedOK (true )
136+ if (numPwns > 0 ){
137+ iconIsPwnedOK (false )
138+ $q .notify ({
139+ message: ' <text-weight-medium>Ce mot de passe est déjà apparu lors d\' une violation de données. Vous ne pouvez pas l\' utiliser</text-weight-medium>' ,
140+ })
141+ emit (' update:modelValue' , ' ' )
142+ return
143+ }else {
144+ iconIsPwnedOK (true )
145+ }
146+ console .log (' pwn :' + numPwns)
144147 }
145- console .log (' pwn :' + numPwns)
146148 }catch (err){
147149
148150 }
@@ -162,33 +164,41 @@ async function checkPassword(ev, type) {
162164function checkPolicy (password ) {
163165 has_len .value = ' highlight_off'
164166 let statut= true
165- if (/ [!@#\$ %\^\& *\)\( +=. _-] / .test (password) === false ){
166- pwdColor .value = ' red'
167- iconSpecialOK (false )
168- statut= false
169- }else {
170- iconSpecialOK (true )
167+ if (props .minSpecial >= 1 ){
168+ if (/ [!@#\$ %\^\& *\)\( +=. _-] / .test (password) === false ){
169+ pwdColor .value = ' red'
170+ iconSpecialOK (false )
171+ statut= false
172+ }else {
173+ iconSpecialOK (true )
174+ }
171175 }
172- if (/ \d / .test (password) === false ){
173- pwdColor .value = ' red'
174- iconNumberOK (false )
175- statut= false
176- }else {
177- iconNumberOK (true )
176+ if (props .minNumber >= 1 ) {
177+ if (/ \d / .test (password) === false ) {
178+ pwdColor .value = ' red'
179+ iconNumberOK (false )
180+ statut = false
181+ } else {
182+ iconNumberOK (true )
183+ }
178184 }
179- if (/ [a-z ] / .test (password) === false ){
180- pwdColor .value = ' red'
181- iconLowerOK (false )
182- statut= false
183- }else {
184- iconLowerOK (true )
185+ if (props .minLower >= 1 ) {
186+ if (/ [a-z ] / .test (password) === false ) {
187+ pwdColor .value = ' red'
188+ iconLowerOK (false )
189+ statut = false
190+ } else {
191+ iconLowerOK (true )
192+ }
185193 }
186- if (/ [A-Z ] / .test (password) === false ){
187- pwdColor .value = ' red'
188- iconUpperOK (false )
189- statut= false
190- }else {
191- iconUpperOK (true )
194+ if (props .minUpper >= 1 ) {
195+ if (/ [A-Z ] / .test (password) === false ) {
196+ pwdColor .value = ' red'
197+ iconUpperOK (false )
198+ statut = false
199+ } else {
200+ iconUpperOK (true )
201+ }
192202 }
193203 if (password .length < props .min ) {
194204 console .log (' trop court ' + props .min )
@@ -277,27 +287,23 @@ function iconIsPwnedOK(value){
277287}
278288function complexity (password ){
279289 console .log (stringEntropy (password))
280- if (props .checkPwned === true ){
281- let c= stringEntropy (password)
282- progress .value = c / 100
290+ if (props .minEntropy > 0 ){
291+ let c = stringEntropy (password)
292+ progress .value = c / 100
283293 console .log (' entropy' + c)
284- if (c < props .entropyBad ){
285- progress_color .value = ' red'
286- }else if (c >= props .entropyBad && c< props .entropyGood ){
287- progress_color .value = ' warning'
288- }else {
289- progress_color .value = ' green'
294+ if (c < props .entropyBad ) {
295+ progress_color .value = ' red'
296+ } else if (c >= props .entropyBad && c < props .entropyGood ) {
297+ progress_color .value = ' warning'
298+ } else {
299+ progress_color .value = ' green'
290300 }
291- if (c >= props .minEntropy ){
301+ if (c >= props .minEntropy ) {
292302 return true
293- }else {
303+ } else {
294304 return false
295305 }
296- }else {
297- return true
298306 }
299-
300-
301307}
302308function togglePassword (){
303309 if (typePasswordProp .value === ' password' ){
0 commit comments