2020 <q-icon :name =" has_len" :color =" has_len_color" size =" xs" style =" margin : 0px ;" ></q-icon >
2121   ; doit avoir au moins {{min}} caractères
2222 </p >
23- <p v-show = " minUpper > 0 " style =" margin : 0px ;" >
23+ <p style =" margin : 0px ;" >
2424 <q-icon :name =" has_upper" :color =" has_upper_color" size =" xs" ></q-icon >
2525   ; doit comporter au moins {{minUpper}} majuscules
2626 </p >
@@ -79,44 +79,29 @@ const progress=ref(0)
7979const progress_color = ref (' red' )
8080const typePasswordProp = ref (' password' )
8181const typeConfirmProp = ref (' password' )
82- const props = defineProps ({
83- min: {
84- type: Number ,
85- default: 8 },
86- minUpper: {
87- type: Number ,
88- default: 1
89- },
90- minLower: {
91- type: Number ,
92- default: 1
93- },
94- minNumber: {
95- type: Number ,
96- default: 1
97- },
98- minSpecial: {
99- type: Number ,
100- default: 1
101- },
102- minEntropy: {
103- type: Number ,
104- default: 30
105- },
106- entropyBad: {
107- type: Number ,
108- default: 10
109- },
110- entropyGood: {
111- type: Number ,
112- default: 80
113- },
114- checkPwned: {
115- type: Boolean ,
116- default: true
117- }
118- })
82+ const minLower = ref (1 )
83+ const minUpper = ref (1 )
84+ const minNumber = ref (1 )
85+ const minSpecial = ref (1 )
86+ const minEntropy = ref (20 )
87+ const checkPwned = ref (false )
88+ const min = ref (5 )
89+ const { data: props } = await useHttp (' /management/passwd/getpolicies' ,
90+ {
91+ method: ' GET' ,
92+ transform : (result )=> {
93+ return result .data
94+ }
11995
96+ }
97+ )
98+ minLower .value = props .value .hasLowerCase
99+ minUpper .value = props .value .hasUpperCase
100+ minNumber .value = props .value .hasNumbers
101+ minSpecial .value = props .value .hasSpecialChars
102+ minEntropy .value = props .value .minComplexity
103+ checkPwned .value = props .value .checkPwned
104+ min .value = props .value .len
120105async function checkPassword (ev , type ) {
121106 let newP = newPassword .value
122107 let confirmP = confirmNewPassword .value
@@ -130,13 +115,16 @@ async function checkPassword(ev, type) {
130115 console .log (' emit ' + newPassword .value )
131116 // avant d accepter on cherche dans l api de pwned
132117 try {
133- if (props . checkPwned === true ){
118+ if (checkPwned . value === true ){
134119 const numPwns = await pwnedPassword (newP);
135120
136121 if (numPwns > 0 ){
137122 iconIsPwnedOK (false )
138123 $q .notify ({
139124 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>' ,
125+ html: true ,
126+ color: ' negative' ,
127+ multiLine: true ,
140128 })
141129 emit (' update:modelValue' , ' ' )
142130 return
@@ -164,7 +152,7 @@ async function checkPassword(ev, type) {
164152function checkPolicy (password ) {
165153 has_len .value = ' highlight_off'
166154 let statut= true
167- if (props . minSpecial >= 1 ){
155+ if (minSpecial . value >= 1 ){
168156 if (/ [!@#\$ %\^\& *\)\( +=. _-] / .test (password) === false ){
169157 pwdColor .value = ' red'
170158 iconSpecialOK (false )
@@ -173,7 +161,7 @@ function checkPolicy(password) {
173161 iconSpecialOK (true )
174162 }
175163 }
176- if (props . minNumber >= 1 ) {
164+ if (minNumber . value >= 1 ) {
177165 if (/ \d / .test (password) === false ) {
178166 pwdColor .value = ' red'
179167 iconNumberOK (false )
@@ -182,7 +170,7 @@ function checkPolicy(password) {
182170 iconNumberOK (true )
183171 }
184172 }
185- if (props . minLower >= 1 ) {
173+ if (minLower . value >= 1 ) {
186174 if (/ [a-z ] / .test (password) === false ) {
187175 pwdColor .value = ' red'
188176 iconLowerOK (false )
@@ -191,7 +179,7 @@ function checkPolicy(password) {
191179 iconLowerOK (true )
192180 }
193181 }
194- if (props . minUpper >= 1 ) {
182+ if (minUpper . value >= 1 ) {
195183 if (/ [A-Z ] / .test (password) === false ) {
196184 pwdColor .value = ' red'
197185 iconUpperOK (false )
@@ -200,8 +188,8 @@ function checkPolicy(password) {
200188 iconUpperOK (true )
201189 }
202190 }
203- if (password .length < props . min ) {
204- console .log (' trop court ' + props . min )
191+ if (password .length < min . value ) {
192+ console .log (' trop court ' + min . value )
205193 iconLenOK (false )
206194 statut= false
207195 }else {
@@ -287,18 +275,18 @@ function iconIsPwnedOK(value){
287275}
288276function complexity (password ){
289277 console .log (stringEntropy (password))
290- if (props . minEntropy > 0 ){
278+ if (minEntropy . value > 0 ){
291279 let c = stringEntropy (password)
292280 progress .value = c / 100
293281 console .log (' entropy' + c)
294- if (c < props .entropyBad ) {
282+ if (c < props .value . minComplexity ) {
295283 progress_color .value = ' red'
296- } else if (c >= props .entropyBad && c < props .entropyGood ) {
284+ } else if (c >= props .value . minComplexity && c < props .value . goodComplexity ) {
297285 progress_color .value = ' warning'
298286 } else {
299287 progress_color .value = ' green'
300288 }
301- if (c >= props . minEntropy ) {
289+ if (c >= minEntropy . value ) {
302290 return true
303291 } else {
304292 return false
0 commit comments