Skip to content

Commit 7649c94

Browse files
committed
fix(docs): add interceptor to mock password validation
- tests given payload length only Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
1 parent f57b50c commit 7649c94

2 files changed

Lines changed: 24 additions & 7 deletions

File tree

src/components/NcPasswordField/NcPasswordField.vue

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ General purpose password field component.
1919
<NcPasswordField id="textField"
2020
v-model="text2"
2121
:label-outside="true"
22-
placeholder="Min. 12 characters" />
22+
placeholder="Min. 12 characters"
23+
:success="true"
24+
helper-text="Password is secure" />
2325
</div>
2426
<div class="external-label">
2527
<label for="textField2">New password</label>
@@ -32,10 +34,9 @@ General purpose password field component.
3234
</div>
3335

3436
<NcPasswordField v-model="text4"
35-
label="Good new password"
36-
:success="true"
37-
placeholder="Min. 12 characters"
38-
helper-text="Password is secure" />
37+
label="Validate new password"
38+
check-password-strength
39+
placeholder="Min. 12 characters" />
3940

4041
<NcPasswordField v-model="text5"
4142
:disabled="true"
@@ -51,7 +52,7 @@ export default {
5152
data() {
5253
return {
5354
text1: '',
54-
text2: '',
55+
text2: 'FWZxt29XEoTQfnBEa',
5556
text3: 'hunter',
5657
text4: '',
5758
text5: '',

styleguide/global.requires.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const USER_GROUPS = [
3030
* @param {object} error Axios error
3131
*/
3232
function mockRequests(error) {
33-
const { request } = error
33+
const { request, config } = error
3434
let data = null
3535

3636
// Mock requesting groups
@@ -39,6 +39,22 @@ function mockRequests(error) {
3939
data = { groups: USER_GROUPS.filter((e) => !requestGroups[1] || e.displayname.startsWith(requestGroups[1]) || e.id.startsWith(requestGroups[1])) }
4040
}
4141

42+
const requestPasswordPolicy = request.responseURL.match(/apps\/password_policy\/api\/v1\/validate/)
43+
if (requestPasswordPolicy) {
44+
const payload = typeof config.data === 'string' ? JSON.parse(config.data) : config.data
45+
46+
if (payload.password.length < 12) {
47+
data = {
48+
passed: false,
49+
reason: 'Password needs to be at least 12 characters long',
50+
}
51+
} else {
52+
data = {
53+
passed: true,
54+
}
55+
}
56+
}
57+
4258
if (data) {
4359
return Promise.resolve({ data: { ocs: { data } } })
4460
}

0 commit comments

Comments
 (0)