bfg-common 1.4.317 → 1.4.319
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/common/layout/theHeader/userMenu/modals/changePassword/ChangePassword.vue +5 -4
- package/components/common/layout/theHeader/userMenu/modals/changePassword/ChangePasswordNew.vue +40 -28
- package/components/common/layout/theHeader/userMenu/modals/changePassword/lib/models/interfaces.ts +6 -1
- package/components/common/layout/theHeader/userMenu/modals/changePassword/lib/utils.ts +17 -0
- package/package.json +1 -1
package/components/common/layout/theHeader/userMenu/modals/changePassword/ChangePassword.vue
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
v-model="form"
|
|
5
5
|
:subtitle="props.hostname"
|
|
6
6
|
:project="props.project"
|
|
7
|
-
@hide="onHideModal"
|
|
8
7
|
@change-password="onChangePassword"
|
|
8
|
+
@hide="onHideModal"
|
|
9
9
|
/>
|
|
10
10
|
|
|
11
11
|
<common-layout-the-header-user-menu-modals-change-password-old
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
v-model="form"
|
|
14
14
|
:hostname="props.hostname"
|
|
15
15
|
:project="props.project"
|
|
16
|
-
@hide="onHideModal"
|
|
17
16
|
@apply="onChangePassword"
|
|
17
|
+
@hide="onHideModal"
|
|
18
18
|
/>
|
|
19
19
|
</template>
|
|
20
20
|
|
|
@@ -23,9 +23,10 @@ import type { UI_I_Localization } from '~/lib/models/interfaces'
|
|
|
23
23
|
import type { API_UI_I_Error } from '~/lib/models/store/interfaces'
|
|
24
24
|
import type {
|
|
25
25
|
UI_I_ChangePasswordBodyRequest,
|
|
26
|
-
|
|
26
|
+
UI_I_ChangePasswordForm,
|
|
27
27
|
} from '~/components/common/layout/theHeader/userMenu/modals/changePassword/lib/models/interfaces'
|
|
28
28
|
import type { UI_T_Project } from '~/lib/models/types'
|
|
29
|
+
import {} from '#build/components/common/layout/theHeader/userMenu/modals/changePassword/lib/models/interfaces'
|
|
29
30
|
|
|
30
31
|
const props = defineProps<{
|
|
31
32
|
newView: boolean
|
|
@@ -37,7 +38,7 @@ const isShowModalLocal = defineModel<boolean>({ required: true })
|
|
|
37
38
|
const localization = computed<UI_I_Localization>(() => useLocal())
|
|
38
39
|
const { $store }: any = useNuxtApp()
|
|
39
40
|
|
|
40
|
-
const form = ref<
|
|
41
|
+
const form = ref<UI_I_ChangePasswordForm>({
|
|
41
42
|
current_password: '',
|
|
42
43
|
new_password: '',
|
|
43
44
|
confirm_password: '',
|
package/components/common/layout/theHeader/userMenu/modals/changePassword/ChangePasswordNew.vue
CHANGED
|
@@ -6,21 +6,21 @@
|
|
|
6
6
|
:subtitle="props.subtitle"
|
|
7
7
|
class="change-password"
|
|
8
8
|
@submit="onSubmit"
|
|
9
|
+
@hide="onHideModal"
|
|
9
10
|
>
|
|
10
11
|
<template #content>
|
|
11
12
|
<ui-modal-block-standard>
|
|
12
13
|
<ui-alert
|
|
13
|
-
v-if="
|
|
14
|
+
v-if="alertErrorText"
|
|
14
15
|
test-id="change-password-error-alert"
|
|
15
16
|
type="error"
|
|
16
17
|
hide-close-button
|
|
17
|
-
:messages="[
|
|
18
|
+
:messages="[alertErrorText]"
|
|
18
19
|
class="change-password__alert"
|
|
19
20
|
/>
|
|
20
21
|
|
|
21
22
|
<p class="change-password__description">
|
|
22
|
-
|
|
23
|
-
is different from any of your previous passwords.
|
|
23
|
+
{{ localization.common.changePasswordDesc }}
|
|
24
24
|
</p>
|
|
25
25
|
|
|
26
26
|
<div class="change-password__form">
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
:label="localization.auth.password"
|
|
31
31
|
:error="passwordErrorText"
|
|
32
32
|
type="password"
|
|
33
|
+
:autocomplete="'new-password'"
|
|
33
34
|
></ui-input>
|
|
34
35
|
|
|
35
36
|
<ui-input
|
|
@@ -57,10 +58,13 @@
|
|
|
57
58
|
|
|
58
59
|
<script setup lang="ts">
|
|
59
60
|
import type { UI_I_Localization } from '~//lib/models/interfaces'
|
|
60
|
-
import type {
|
|
61
|
+
import type { UI_I_ChangePasswordForm } from '~/components/common/layout/theHeader/userMenu/modals/changePassword/lib/models/interfaces'
|
|
61
62
|
import type { UI_T_Project } from '~/lib/models/types'
|
|
62
63
|
import type { UI_I_InitialValidationFields } from '~/components/common/layout/theHeader/userMenu/modals/changePassword/lib/models/interfaces'
|
|
63
|
-
import {
|
|
64
|
+
import {
|
|
65
|
+
validateField,
|
|
66
|
+
getPasswordMismatchError,
|
|
67
|
+
} from '~/components/common/layout/theHeader/userMenu/modals/changePassword/lib/utils'
|
|
64
68
|
|
|
65
69
|
const props = defineProps<{
|
|
66
70
|
project: UI_T_Project
|
|
@@ -70,17 +74,25 @@ const emits = defineEmits<{
|
|
|
70
74
|
(event: 'hide'): void
|
|
71
75
|
(event: 'change-password'): void
|
|
72
76
|
}>()
|
|
73
|
-
const modelLocal = defineModel<
|
|
77
|
+
const modelLocal = defineModel<UI_I_ChangePasswordForm>({ required: true })
|
|
74
78
|
|
|
75
79
|
const localization = computed<UI_I_Localization>(() => useLocal())
|
|
76
80
|
|
|
81
|
+
|
|
82
|
+
const alertErrorText = ref<string>('')
|
|
77
83
|
const initValidationFields = ref<UI_I_InitialValidationFields>({
|
|
78
84
|
currentPassword: false,
|
|
79
85
|
newPassword: false,
|
|
80
86
|
confirmPassword: false,
|
|
81
87
|
})
|
|
82
|
-
const initValidation = (types: string[]):
|
|
88
|
+
const initValidation = (types: string[]): boolean => {
|
|
83
89
|
types.forEach((type) => (initValidationFields.value[type] = true))
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
!!passwordErrorText.value ||
|
|
93
|
+
!!newPasswordErrorText.value ||
|
|
94
|
+
!!confirmPasswordErrorText.value
|
|
95
|
+
)
|
|
84
96
|
}
|
|
85
97
|
|
|
86
98
|
const passwordErrorText = computed<string>(() => {
|
|
@@ -91,7 +103,7 @@ const passwordErrorText = computed<string>(() => {
|
|
|
91
103
|
: ''
|
|
92
104
|
})
|
|
93
105
|
const newPasswordErrorText = computed<string>(() => {
|
|
94
|
-
if (!initValidationFields.value.
|
|
106
|
+
if (!initValidationFields.value.newPassword) return ''
|
|
95
107
|
|
|
96
108
|
const { new_password, confirm_password } = modelLocal.value
|
|
97
109
|
return !new_password
|
|
@@ -103,7 +115,7 @@ const newPasswordErrorText = computed<string>(() => {
|
|
|
103
115
|
)
|
|
104
116
|
})
|
|
105
117
|
const confirmPasswordErrorText = computed<string>(() => {
|
|
106
|
-
if (!initValidationFields.value.
|
|
118
|
+
if (!initValidationFields.value.confirmPassword) return ''
|
|
107
119
|
const { new_password, confirm_password } = modelLocal.value
|
|
108
120
|
return !confirm_password
|
|
109
121
|
? localization.value.common.fieldRequired
|
|
@@ -113,25 +125,22 @@ const confirmPasswordErrorText = computed<string>(() => {
|
|
|
113
125
|
confirm_password
|
|
114
126
|
)
|
|
115
127
|
})
|
|
116
|
-
|
|
117
|
-
// const isValid = ref<boolean>(false)
|
|
118
|
-
const errorText = ref<string>('')
|
|
119
|
-
|
|
120
|
-
// const showValidationErrors = (text: string): void => {
|
|
121
|
-
// isValid.value = true
|
|
122
|
-
// errorText.value = text
|
|
123
|
-
// }
|
|
124
|
-
|
|
125
|
-
// const onHideModal = (): void => {
|
|
126
|
-
// emits('hide')
|
|
127
|
-
// setForm()
|
|
128
|
-
// isValid.value = false
|
|
129
|
-
// }
|
|
130
|
-
|
|
131
128
|
const onSubmit = (): void => {
|
|
132
|
-
initValidation([
|
|
133
|
-
|
|
134
|
-
|
|
129
|
+
const isFieldValid = initValidation([
|
|
130
|
+
'currentPassword',
|
|
131
|
+
'newPassword',
|
|
132
|
+
'confirmPassword',
|
|
133
|
+
])
|
|
134
|
+
|
|
135
|
+
const { current_password, new_password } = modelLocal.value
|
|
136
|
+
|
|
137
|
+
if (!isFieldValid) {
|
|
138
|
+
alertErrorText.value = validateField(
|
|
139
|
+
localization.value,
|
|
140
|
+
current_password,
|
|
141
|
+
new_password
|
|
142
|
+
)
|
|
143
|
+
}
|
|
135
144
|
|
|
136
145
|
const notReady = true
|
|
137
146
|
if (notReady) {
|
|
@@ -139,6 +148,9 @@ const onSubmit = (): void => {
|
|
|
139
148
|
}
|
|
140
149
|
emits('change-password')
|
|
141
150
|
}
|
|
151
|
+
const onHideModal = (): void => {
|
|
152
|
+
emits('hide')
|
|
153
|
+
}
|
|
142
154
|
</script>
|
|
143
155
|
|
|
144
156
|
<style lang="scss" scoped>
|
package/components/common/layout/theHeader/userMenu/modals/changePassword/lib/models/interfaces.ts
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import type { UI_I_Validation } from '~/lib/models/plugins/validation/interfaces'
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
export interface UI_I_InitialValidationFields {
|
|
5
4
|
currentPassword: boolean
|
|
6
5
|
newPassword: boolean
|
|
7
6
|
confirmPassword: boolean
|
|
8
7
|
}
|
|
8
|
+
|
|
9
|
+
export interface UI_I_ChangePasswordForm {
|
|
10
|
+
current_password: string
|
|
11
|
+
new_password: string
|
|
12
|
+
confirm_password: string
|
|
13
|
+
}
|
|
9
14
|
export interface UI_I_FormChangePassword {
|
|
10
15
|
password: UI_I_Validation
|
|
11
16
|
newPassword: UI_I_Validation
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { UI_I_Localization } from '~//lib/models/interfaces'
|
|
2
|
+
import { RegExp } from '~/lib/config/regExp'
|
|
2
3
|
|
|
3
4
|
export const getPasswordMismatchError = (
|
|
4
5
|
localization: UI_I_Localization,
|
|
@@ -9,3 +10,19 @@ export const getPasswordMismatchError = (
|
|
|
9
10
|
? ''
|
|
10
11
|
: localization.common.thePasswordsDoNotMatch
|
|
11
12
|
}
|
|
13
|
+
|
|
14
|
+
export const validateField = (
|
|
15
|
+
localization: UI_I_Localization,
|
|
16
|
+
password: string,
|
|
17
|
+
newPassword: string
|
|
18
|
+
): string => {
|
|
19
|
+
if (!RegExp.password.test(newPassword)) {
|
|
20
|
+
return localization.common.currentPasswordIncorrect
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (password === newPassword) {
|
|
24
|
+
return localization.common.changePasswordPreviouslyUsed
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return ''
|
|
28
|
+
}
|