bfg-common 1.4.318 → 1.4.320
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 +18 -14
- 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,15 +6,16 @@
|
|
|
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
|
|
|
@@ -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,10 +74,12 @@ 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,
|
|
@@ -119,25 +125,23 @@ const confirmPasswordErrorText = computed<string>(() => {
|
|
|
119
125
|
confirm_password
|
|
120
126
|
)
|
|
121
127
|
})
|
|
122
|
-
|
|
123
|
-
// const isValid = ref<boolean>(false)
|
|
124
|
-
const errorText = ref<string>('')
|
|
125
|
-
|
|
126
|
-
|
|
127
128
|
const onSubmit = (): void => {
|
|
128
129
|
const isFieldValid = initValidation([
|
|
129
130
|
'currentPassword',
|
|
130
131
|
'newPassword',
|
|
131
132
|
'confirmPassword',
|
|
132
133
|
])
|
|
133
|
-
|
|
134
|
+
|
|
135
|
+
const { current_password, new_password } = modelLocal.value
|
|
134
136
|
|
|
135
137
|
if (!isFieldValid) {
|
|
136
|
-
|
|
138
|
+
alertErrorText.value = validateField(
|
|
139
|
+
localization.value,
|
|
140
|
+
current_password,
|
|
141
|
+
new_password
|
|
142
|
+
)
|
|
137
143
|
}
|
|
138
144
|
|
|
139
|
-
errorText.value = 'asdaldjlkdjkadj'
|
|
140
|
-
|
|
141
145
|
const notReady = true
|
|
142
146
|
if (notReady) {
|
|
143
147
|
return
|
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
|
+
}
|