|
11 | 11 | const passwordValidityLabels: { [K in PolicyKey]: string } = { |
12 | 12 | include_digits: 'Include %s numbers', |
13 | 13 | include_lower_case: 'Include %s lowercase', |
14 | | - include_upper_case: 'Include &s uppercase', |
| 14 | + include_upper_case: 'Include %s uppercase', |
15 | 15 | include_special: 'Include %s special characters', |
16 | 16 | length_max: 'Shorter than %s', |
17 | 17 | length_min: 'At least %s long', |
|
23 | 23 | let passwordValidity: { [K in PolicyKey]?: { label: string; valid?: boolean } } = $state( |
24 | 24 | Object.fromEntries( |
25 | 25 | Object.entries(data.passwordPolicy) |
| 26 | + .filter(([key, _]) => !!passwordValidityLabels[key as PolicyKey]) |
26 | 27 | .filter(([_, value]) => !!value) |
27 | | - .map(([key, value]) => [ |
28 | | - key, |
29 | | - { |
30 | | - label: passwordValidityLabels[key as PolicyKey].replace('%s', value.toString()), |
31 | | - valid: false |
32 | | - } |
33 | | - ]) |
| 28 | + .map(([key, value]) => { |
| 29 | + console.log(key, value); |
| 30 | + return [ |
| 31 | + key, |
| 32 | + { |
| 33 | + label: passwordValidityLabels[key as PolicyKey].replace('%s', value.toString()), |
| 34 | + valid: false |
| 35 | + } |
| 36 | + ]; |
| 37 | + }) |
34 | 38 | ) |
35 | 39 | ); |
36 | 40 | let passwordValid = $derived(Object.values(passwordValidity).every((x) => x.valid !== false)); |
|
75 | 79 | try { |
76 | 80 | const resp = await fetch(`/auth/v1/users/${data.user}/reset`, { |
77 | 81 | method: 'put', |
78 | | - headers: [['pwd-csrf-token', data.csrfToken!]], |
| 82 | + headers: [ |
| 83 | + ['x-pwd-csrf-token', data.csrfToken!], |
| 84 | + ['content-type', 'application/json'] |
| 85 | + ], |
79 | 86 | body: JSON.stringify({ magic_link_id: data.token, password }) |
80 | 87 | }); |
81 | 88 | await checkResponse(resp); |
|
0 commit comments