adata-ui 2.0.23 → 2.0.25

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.
@@ -1,19 +1,53 @@
1
1
  <script setup lang="ts">
2
- import IdEmailModal from '#adata-ui/components/modals/id/IdEmailModal.vue'
2
+ import IdConfirmAccountOtpModal from '#adata-ui/components/modals/id/IdConfirmAccountOtpModal.vue'
3
+ import IdConfirmSuccessfulModal from '#adata-ui/components/modals/id/IdConfirmSuccessfulModal.vue'
3
4
  import IdLoginModal from '#adata-ui/components/modals/id/IdLoginModal.vue'
4
5
  import IdNewPasswordModal from '#adata-ui/components/modals/id/IdNewPasswordModal.vue'
5
6
  import IdPasswordSuccessfulModal from '#adata-ui/components/modals/id/IdPasswordSuccessfulModal.vue'
6
7
  import IdRecoveryModal from '#adata-ui/components/modals/id/IdRecoveryModal.vue'
7
8
  import IdRegistrationModal from '#adata-ui/components/modals/id/IdRegistrationModal.vue'
9
+ import IdResetPasswordOtpModal from '#adata-ui/components/modals/id/IdResetPasswordOtpModal.vue'
10
+
11
+ const {
12
+ loginModal,
13
+ registrationModal,
14
+ confirmAccountOtpModal,
15
+ recoveryModal,
16
+ resetPasswordOtpModal,
17
+ newPasswordModal,
18
+ passwordSuccessfulModal,
19
+ confirmSuccessfulModal,
20
+ twoFactorModal,
21
+ } = useIdModals()
8
22
  </script>
9
23
 
10
24
  <template>
11
- <id-login-modal />
12
- <id-registration-modal />
13
- <id-recovery-modal />
14
- <id-email-modal />
15
- <id-new-password-modal />
16
- <id-password-successful-modal />
25
+ <a-modal v-model="loginModal">
26
+ <id-login-modal />
27
+ </a-modal>
28
+
29
+ <a-modal v-model="registrationModal">
30
+ <id-registration-modal v-if="registrationModal" />
31
+ </a-modal>
32
+ <a-modal v-model="confirmAccountOtpModal">
33
+ <id-confirm-account-otp-modal v-if="confirmAccountOtpModal" />
34
+ </a-modal>
35
+ <a-modal v-model="confirmSuccessfulModal">
36
+ <id-confirm-successful-modal v-if="confirmSuccessfulModal" />
37
+ </a-modal>
38
+
39
+ <a-modal v-model="recoveryModal">
40
+ <id-recovery-modal v-if="recoveryModal" />
41
+ </a-modal>
42
+ <a-modal v-model="resetPasswordOtpModal">
43
+ <id-reset-password-otp-modal v-if="resetPasswordOtpModal" />
44
+ </a-modal>
45
+ <a-modal v-model="newPasswordModal">
46
+ <id-new-password-modal v-if="newPasswordModal" />
47
+ </a-modal>
48
+ <a-modal v-model="passwordSuccessfulModal">
49
+ <id-password-successful-modal v-if="passwordSuccessfulModal" />
50
+ </a-modal>
17
51
  </template>
18
52
 
19
53
  <style scoped></style>
@@ -1,14 +1,16 @@
1
1
  <script setup lang="ts">
2
+ import { useAuthStore } from '#adata-ui/stores/auth.store'
2
3
  import * as z from 'zod'
3
4
 
4
5
  const { $toast } = useNuxtApp()
5
6
  const { commonAuth } = useAppConfig()
6
- const route = useRoute()
7
7
  const { t, locale } = useI18n()
8
8
 
9
- const { email, token } = route.query
9
+ const authStore = useAuthStore()
10
+ const { intermediateState } = storeToRefs(authStore)
11
+
10
12
  const authApiURL = commonAuth.authApiURL
11
- const { loginModal, newPasswordModal, passwordSuccessfulModal } = useIdModals()
13
+ const { newPasswordModal, passwordSuccessfulModal } = useIdModals()
12
14
 
13
15
  const form = reactive({
14
16
  password: '',
@@ -51,22 +53,22 @@ async function onSubmit() {
51
53
  if (validation.value) return
52
54
  loading.value = true
53
55
 
54
- const { data } = await $fetch(`${authApiURL}/password/reset`, {
56
+ const response = await $fetch(`${authApiURL}/password/reset-otp`, {
55
57
  method: 'POST',
56
58
  credentials: 'include',
57
59
  headers: {
58
60
  lang: locale.value,
59
61
  },
60
62
  body: {
61
- token,
62
- email,
63
+ token: intermediateState.value.token,
64
+ email: intermediateState.value.email,
63
65
  ...form,
64
66
  },
65
67
  })
66
- if (data?.success) {
68
+ if (response?.success) {
67
69
  newPasswordModal.value = false
68
70
  passwordSuccessfulModal.value = true
69
- $toast.success(data.message)
71
+ $toast.success(response.message)
70
72
  }
71
73
  }
72
74
  catch (error) {
@@ -76,62 +78,53 @@ async function onSubmit() {
76
78
  loading.value = false
77
79
  }
78
80
  }
79
-
80
- // onMounted(() => {
81
- // if (!email || !token) {
82
- // newPasswordModal.value = false
83
- // loginModal.value = true
84
- // }
85
- // })
86
81
  </script>
87
82
 
88
83
  <template>
89
- <a-modal v-model="newPasswordModal">
90
- <form
91
- class="flex flex-col items-stretch gap-5"
92
- novalidate
93
- @submit.prevent="onSubmit"
84
+ <form
85
+ class="flex flex-col items-stretch gap-5"
86
+ novalidate
87
+ @submit.prevent="onSubmit"
88
+ >
89
+ <h2 class="text-center text-2xl font-bold">
90
+ {{ t('modals.id.newPassword.title') }}
91
+ </h2>
92
+ <p class="text-center text-sm">
93
+ {{ t('modals.id.newPassword.content') }}
94
+ </p>
95
+
96
+ <a-input-password
97
+ v-model="form.password"
98
+ :label="t('modals.id.newPassword.placeholder.1')"
99
+ :error="getError('password')"
100
+ />
101
+
102
+ <a-alert color="blue">
103
+ {{ t('modals.id.newPassword.alert') }}
104
+ </a-alert>
105
+
106
+ <a-input-password
107
+ v-model="form.password_confirmation"
108
+ :label="t('modals.id.newPassword.placeholder.2')"
109
+ :error="getError('password_confirmation')"
110
+ />
111
+
112
+ <a-button
113
+ :loading="loading"
114
+ >
115
+ {{ t('actions.set') }}
116
+ </a-button>
117
+
118
+ <p class="text-center text-sm">
119
+ {{ t('reuse.or') }}
120
+ </p>
121
+
122
+ <a-button
123
+ type="button"
124
+ view="outline"
125
+ @click="newPasswordModal = false"
94
126
  >
95
- <h2 class="text-center text-2xl font-bold">
96
- {{ t('resetPassword.title') }}
97
- </h2>
98
- <p class="text-center text-sm">
99
- {{ t('resetPassword.subtitle') }}
100
- </p>
101
-
102
- <a-input-password
103
- v-model="form.password"
104
- :label="t('register.form.labels.password')"
105
- :error="getError('password')"
106
- />
107
-
108
- <a-alert color="blue">
109
- {{ t('register.form.alert') }}
110
- </a-alert>
111
-
112
- <a-input-password
113
- v-model="form.password_confirmation"
114
- :label="t('register.form.labels.password_confirmation')"
115
- :error="getError('password_confirmation')"
116
- />
117
-
118
- <a-button
119
- :loading="loading"
120
- >
121
- {{ t('passwordRecovery.form.recover') }}
122
- </a-button>
123
-
124
- <p class="text-center text-sm">
125
- {{ t('passwordRecovery.form.or') }}
126
- </p>
127
-
128
- <a-button
129
- type="button"
130
- view="outline"
131
- @click="newPasswordModal = false"
132
- >
133
- {{ t('actions.cancel') }}
134
- </a-button>
135
- </form>
136
- </a-modal>
127
+ {{ t('actions.cancel') }}
128
+ </a-button>
129
+ </form>
137
130
  </template>
@@ -1,24 +1,23 @@
1
1
  <script setup lang="ts">
2
2
  const { passwordSuccessfulModal } = useIdModals()
3
+ const { t } = useI18n()
3
4
  </script>
4
5
 
5
6
  <template>
6
- <a-modal v-model="passwordSuccessfulModal">
7
- <section class="flex flex-col items-stretch gap-4 text-center">
8
- <h2 class="text-2xl font-bold">
9
- {{ $t('resetPassword.successModal.title') }}
10
- </h2>
11
- <span class="mx-auto size-[100px] rounded-full bg-[#BDC7CE26]">
12
- <a-ill-ok />
13
- </span>
14
- <p class="text-sm">
15
- {{ $t('resetPassword.successModal.subtitle') }}
16
- </p>
17
- <a-button @click="passwordSuccessfulModal = false">
18
- {{ $t('resetPassword.successModal.goToAuthorization') }}
19
- </a-button>
20
- </section>
21
- </a-modal>
7
+ <div class="flex flex-col gap-4 text-center">
8
+ <h2 class="text-2xl font-bold">
9
+ {{ t('modals.id.passwordSuccessful.title') }}
10
+ </h2>
11
+ <span class="mx-auto size-[100px] rounded-full bg-[#BDC7CE26]">
12
+ <a-ill-ok />
13
+ </span>
14
+ <p class="text-sm">
15
+ {{ t('modals.id.passwordSuccessful.content') }}
16
+ </p>
17
+ <a-button @click="passwordSuccessfulModal = false">
18
+ {{ t('actions.close') }}
19
+ </a-button>
20
+ </div>
22
21
  </template>
23
22
 
24
23
  <style scoped>
@@ -1,11 +1,15 @@
1
1
  <script setup lang="ts">
2
+ import { useAuthStore } from '#adata-ui/stores/auth.store'
2
3
  import * as z from 'zod'
3
4
 
4
5
  const { $toast } = useNuxtApp()
5
6
  const { commonAuth } = useAppConfig()
6
7
  const { t, locale } = useI18n()
7
8
 
8
- const { recoveryModal, emailModal } = useIdModals()
9
+ const authStore = useAuthStore()
10
+ const { intermediateState } = storeToRefs(authStore)
11
+
12
+ const { recoveryModal, resetPasswordOtpModal } = useIdModals()
9
13
  const authApiURL = commonAuth.authApiURL
10
14
  const emailField = ref('')
11
15
  const loading = ref(false)
@@ -31,7 +35,7 @@ async function onSubmit() {
31
35
  if (validation.value) return
32
36
  loading.value = true
33
37
 
34
- await $fetch(`${authApiURL}/password/email`, {
38
+ await $fetch(`${authApiURL}/password/email-otp`, {
35
39
  method: 'POST',
36
40
  credentials: 'include',
37
41
  headers: {
@@ -41,8 +45,10 @@ async function onSubmit() {
41
45
  email: emailField.value,
42
46
  },
43
47
  })
48
+ intermediateState.value.email = emailField.value
49
+
44
50
  recoveryModal.value = false
45
- emailModal.value = true
51
+ resetPasswordOtpModal.value = true
46
52
  }
47
53
  catch (error) {
48
54
  $toast.error(error.data.message)
@@ -51,6 +57,7 @@ async function onSubmit() {
51
57
  loading.value = false
52
58
  }
53
59
  }
60
+
54
61
  function handleEnter(e: KeyboardEvent) {
55
62
  if (e.key === 'Enter') {
56
63
  onSubmit()
@@ -77,38 +84,36 @@ onBeforeUnmount(() => {
77
84
  </script>
78
85
 
79
86
  <template>
80
- <a-modal v-model="recoveryModal">
81
- <form
82
- class="flex flex-col items-stretch gap-5 rounded-lg text-center"
83
- novalidate
84
- @submit.prevent="onSubmit"
87
+ <form
88
+ class="flex flex-col items-stretch gap-5 rounded-lg text-center"
89
+ novalidate
90
+ @submit.prevent="onSubmit"
91
+ >
92
+ <h2 class="text-center text-2xl font-bold">
93
+ {{ t('modals.id.recovery.title') }}
94
+ </h2>
95
+ <p class="text-center text-sm">
96
+ {{ t('modals.id.recovery.content') }}
97
+ </p>
98
+ <a-input-standard
99
+ v-model="emailField"
100
+ :label="t('modals.id.recovery.placeholder')"
101
+ :error="getError('emailField')"
102
+ />
103
+ <a-button :loading="loading">
104
+ {{ t('actions.recover') }}
105
+ </a-button>
106
+ <p class="text-center text-sm">
107
+ {{ t('reuse.or') }}
108
+ </p>
109
+ <a-button
110
+ type="button"
111
+ view="outline"
112
+ @click="onCancel"
85
113
  >
86
- <h2 class="text-center text-2xl font-bold">
87
- {{ t('modals.id.recovery.title') }}
88
- </h2>
89
- <p class="text-center text-sm">
90
- {{ t('modals.id.recovery.content') }}
91
- </p>
92
- <a-input-standard
93
- v-model="emailField"
94
- :label="t('modals.id.recovery.placeholder')"
95
- :error="getError('emailField')"
96
- />
97
- <a-button :loading="loading">
98
- {{ t('actions.recover') }}
99
- </a-button>
100
- <p class="text-center text-sm">
101
- {{ t('reuse.or') }}
102
- </p>
103
- <a-button
104
- type="button"
105
- view="outline"
106
- @click="onCancel"
107
- >
108
- {{ t('actions.cancel') }}
109
- </a-button>
110
- </form>
111
- </a-modal>
114
+ {{ t('actions.cancel') }}
115
+ </a-button>
116
+ </form>
112
117
  </template>
113
118
 
114
119
  <style scoped></style>
@@ -1,21 +1,22 @@
1
1
  <script setup lang="ts">
2
- import Accept from '#adata-ui/components/modals/Accept.vue'
3
2
  import { PAGES } from '#adata-ui/shared/constans/pages'
4
- import { useToggle } from '@vueuse/shared'
3
+ import { useAuthStore } from '#adata-ui/stores/auth.store'
5
4
 
6
5
  import { computed, reactive, ref } from 'vue'
7
-
8
6
  import * as z from 'zod'
9
7
 
10
8
  const { $toast } = useNuxtApp()
11
9
  const route = useRoute()
12
10
 
11
+ const authStore = useAuthStore()
12
+ const { intermediateState } = storeToRefs(authStore)
13
+
13
14
  const localePath = useLocalePath()
14
15
  const { t, locale } = useI18n()
15
16
  const { myLayer, commonAuth }: any = useAppConfig()
16
17
  const authApiURL = commonAuth.authApiURL
17
18
  const redirectUrl = useCookie('redirect_url')
18
- const { loginModal, registrationModal } = useIdModals()
19
+ const { loginModal, registrationModal, confirmAccountOtpModal } = useIdModals()
19
20
 
20
21
  export interface RegistrationForm {
21
22
  email: string
@@ -29,7 +30,6 @@ const form = reactive<RegistrationForm>({
29
30
  password_confirmation: '',
30
31
  })
31
32
 
32
- const [isAcceptModal, toggleAcceptModal] = useToggle()
33
33
  const agreement = ref(false)
34
34
  const loading = ref(false)
35
35
 
@@ -74,7 +74,7 @@ async function onSubmit() {
74
74
 
75
75
  try {
76
76
  loading.value = true
77
- const { data, message } = await $fetch(`${authApiURL}/register`, {
77
+ const { success, message } = await $fetch(`${authApiURL}/register`, {
78
78
  method: 'POST',
79
79
  credentials: 'include',
80
80
  headers: {
@@ -82,9 +82,10 @@ async function onSubmit() {
82
82
  },
83
83
  body: form,
84
84
  })
85
- if (data) {
85
+ if (success) {
86
+ intermediateState.value.email = form.email
86
87
  registrationModal.value = false
87
- toggleAcceptModal()
88
+ confirmAccountOtpModal.value = true
88
89
  $toast.success(message)
89
90
  }
90
91
  }
@@ -100,30 +101,10 @@ if (route.query.url) {
100
101
  redirectUrl.value = route.query.url as string
101
102
  }
102
103
 
103
- function goBack() {
104
- isAcceptModal.value = false
105
- }
106
-
107
104
  // onMounted(() => {
108
105
  // v$.value.$touch();
109
106
  // });
110
107
 
111
- async function onResend() {
112
- const emailResend = await fetch(`${authApiURL}/email/resend`, {
113
- method: 'GET',
114
- credentials: 'include',
115
- headers: {
116
- lang: locale.value,
117
- },
118
- })
119
- const { data, success, message } = await emailResend.json()
120
- if (success) {
121
- toggleAcceptModal()
122
- loading.value = false
123
- $toast.success(message)
124
- }
125
- }
126
-
127
108
  function getUrl() {
128
109
  return navigateTo(locale.value !== 'ru'
129
110
  ? myLayer.landingUrl + localePath('/') + PAGES.userAgreement
@@ -136,7 +117,7 @@ function getUrl() {
136
117
  }
137
118
 
138
119
  function handleEnter(event: KeyboardEvent) {
139
- if (event.key === 'Enter' && !isAcceptModal.value) {
120
+ if (event.key === 'Enter' && !confirmAccountOtpModal.value) {
140
121
  onSubmit()
141
122
  }
142
123
  }
@@ -165,80 +146,71 @@ onBeforeUnmount(() => {
165
146
  </script>
166
147
 
167
148
  <template>
168
- <a-modal v-model="registrationModal">
169
- <form
170
- class="flex flex-col items-stretch gap-5"
171
- novalidate
172
- @submit.prevent="onSubmit"
149
+ <form
150
+ class="flex flex-col items-stretch gap-5"
151
+ novalidate
152
+ @submit.prevent="onSubmit"
153
+ >
154
+ <h2 class="text-center text-2xl font-bold">
155
+ {{ t('register.form.title') }}
156
+ </h2>
157
+ <p class="text-center text-sm">
158
+ {{ t('register.form.subtitle') }}
159
+ </p>
160
+ <a-input-standard
161
+ v-model="form.email"
162
+ :label="t('register.form.labels.email')"
163
+ :error="getError('email')"
164
+ type="email"
165
+ />
166
+
167
+ <a-input-password
168
+ v-model="form.password"
169
+ :label="t('register.form.labels.password')"
170
+ :error="getError('password')"
171
+ />
172
+
173
+ <a-input-password
174
+ v-model="form.password_confirmation"
175
+ :label="t('register.form.labels.password_confirmation')"
176
+ :error="getError('password_confirmation')"
177
+ />
178
+ <a-alert color="blue">
179
+ {{ t('register.form.alert') }}
180
+ <template #icon>
181
+ <a-icon-info-circle />
182
+ </template>
183
+ </a-alert>
184
+ <a-checkbox
185
+ v-model="agreement"
186
+ side="right"
173
187
  >
174
- <h2 class="text-center text-2xl font-bold">
175
- {{ t('register.form.title') }}
176
- </h2>
177
- <p class="text-center text-sm">
178
- {{ t('register.form.subtitle') }}
179
- </p>
180
- <a-input-standard
181
- v-model="form.email"
182
- :label="t('register.form.labels.email')"
183
- :error="getError('email')"
184
- type="email"
185
- />
186
-
187
- <a-input-password
188
- v-model="form.password"
189
- :label="t('register.form.labels.password')"
190
- :error="getError('password')"
191
- />
192
-
193
- <a-input-password
194
- v-model="form.password_confirmation"
195
- :label="t('register.form.labels.password_confirmation')"
196
- :error="getError('password_confirmation')"
197
- />
198
- <a-alert color="blue">
199
- {{ t('register.form.alert') }}
200
- <template #icon>
201
- <a-icon-info-circle />
188
+ <i18n-t keypath="register.form.agreement.text">
189
+ <template #link>
190
+ <nuxt-link-locale
191
+ class="text-blue-700"
192
+ @click="getUrl"
193
+ >
194
+ {{ t('register.form.agreement.link') }}
195
+ </nuxt-link-locale>
202
196
  </template>
203
- </a-alert>
204
- <a-checkbox
205
- v-model="agreement"
206
- side="right"
207
- >
208
- <i18n-t keypath="register.form.agreement.text">
209
- <template #link>
210
- <nuxt-link-locale
211
- class="text-blue-700"
212
- @click="getUrl"
213
- >
214
- {{ t('register.form.agreement.link') }}
215
- </nuxt-link-locale>
216
- </template>
217
- </i18n-t>
218
- </a-checkbox>
219
- <a-button
220
- :disabled="!agreement"
221
- :loading="loading"
222
- >
223
- {{ t('register.form.continue') }}
224
- </a-button>
225
- <p class="text-center text-sm">
226
- {{ t('register.form.haveAcc') }}
227
- </p>
228
- <a-button
229
- type="button"
230
- view="outline"
231
- @click="onLogin"
232
- >
233
- {{ t('register.form.enter') }}
234
- </a-button>
235
- </form>
236
- </a-modal>
237
- <a-modal v-model="isAcceptModal">
238
- <accept
239
- v-if="isAcceptModal"
240
- @back="goBack"
241
- @repeated="onResend"
242
- />
243
- </a-modal>
197
+ </i18n-t>
198
+ </a-checkbox>
199
+ <a-button
200
+ :disabled="!agreement"
201
+ :loading="loading"
202
+ >
203
+ {{ t('register.form.continue') }}
204
+ </a-button>
205
+ <p class="text-center text-sm">
206
+ {{ t('register.form.haveAcc') }}
207
+ </p>
208
+ <a-button
209
+ type="button"
210
+ view="outline"
211
+ @click="onLogin"
212
+ >
213
+ {{ t('register.form.enter') }}
214
+ </a-button>
215
+ </form>
244
216
  </template>