pukaad-ui-lib 1.274.0 → 1.276.0

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/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pukaad-ui-lib",
3
3
  "configKey": "pukaadUI",
4
- "version": "1.274.0",
4
+ "version": "1.276.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -9,11 +9,13 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
9
9
  } & {
10
10
  complete: (data: {
11
11
  token: string;
12
+ code?: string;
12
13
  }) => any;
13
14
  }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
14
15
  "onUpdate:modelValue"?: ((value: boolean) => any) | undefined;
15
16
  onComplete?: ((data: {
16
17
  token: string;
18
+ code?: string;
17
19
  }) => any) | undefined;
18
20
  }>, {
19
21
  confirmedText: string;
@@ -60,7 +60,7 @@ const onVerify2FA = async () => {
60
60
  }
61
61
  );
62
62
  if (!data) throw "error";
63
- emit("complete", data);
63
+ emit("complete", { ...data, code: valueOTP.value });
64
64
  isOpen.value = false;
65
65
  } catch (e) {
66
66
  const errorMessage = "\u0E23\u0E2B\u0E31\u0E2A\u0E22\u0E37\u0E19\u0E22\u0E31\u0E19\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07";
@@ -9,11 +9,13 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
9
9
  } & {
10
10
  complete: (data: {
11
11
  token: string;
12
+ code?: string;
12
13
  }) => any;
13
14
  }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
14
15
  "onUpdate:modelValue"?: ((value: boolean) => any) | undefined;
15
16
  onComplete?: ((data: {
16
17
  token: string;
18
+ code?: string;
17
19
  }) => any) | undefined;
18
20
  }>, {
19
21
  confirmedText: string;
@@ -1,10 +1,13 @@
1
1
  interface Props {
2
+ mode?: "login" | "secure";
2
3
  title?: string;
3
4
  confirmText?: string;
4
5
  loginToken?: string;
5
6
  /** When provided, uses forgot-password reset endpoint instead of password/create */
6
7
  resetToken?: string;
7
8
  disabledForceLogout?: boolean;
9
+ oldPassword?: string;
10
+ twoFaCode?: string;
8
11
  }
9
12
  type __VLS_Props = Props;
10
13
  type __VLS_ModelProps = {
@@ -25,6 +28,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
25
28
  } | null) => any) | undefined;
26
29
  }>, {
27
30
  title: string;
31
+ mode: "login" | "secure";
28
32
  confirmText: string;
29
33
  disabledForceLogout: boolean;
30
34
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -1,34 +1,14 @@
1
1
  <template>
2
- <Modal
3
- :title="props.title"
4
- :loading="loading"
5
- v-model="isOpen"
6
- @close="emit('close')"
7
- @submit="handleSubmit"
8
- width="425px"
9
- >
2
+ <Modal :title="props.title" :loading="loading" v-model="isOpen" @close="emit('close')" @submit="handleSubmit"
3
+ width="425px">
10
4
  <div class="flex flex-col gap-2">
11
- <InputPassword
12
- disabled-forgot-password
13
- new
14
- required
15
- label="รหัสผ่าน"
16
- placeholder="กรอกรหัสผ่าน"
17
- v-model="password"
18
- />
19
- <InputCheckbox
20
- v-if="!props.disabledForceLogout"
21
- label="ออกจากระบบ Pukaad ในอุปกรณ์อื่นๆทั้งหมด"
22
- v-model="logoutAll"
23
- />
5
+ <InputPassword disabled-forgot-password new required label="รหัสผ่าน" placeholder="กรอกรหัสผ่าน"
6
+ v-model="password" />
7
+ <InputCheckbox v-if="!props.disabledForceLogout" label="ออกจากระบบ Pukaad ในอุปกรณ์อื่นๆทั้งหมด"
8
+ v-model="logoutAll" />
24
9
  </div>
25
10
  <template #footer="{ meta }">
26
- <Button
27
- type="submit"
28
- color="primary"
29
- class="w-full"
30
- :disabled="!meta.valid"
31
- >
11
+ <Button type="submit" color="primary" class="w-full" :disabled="!meta.valid">
32
12
  {{ props.confirmText }}
33
13
  </Button>
34
14
  </template>
@@ -40,11 +20,14 @@ import { ref, computed, watch } from "vue";
40
20
  import { useNuxtApp, useRuntimeConfig } from "nuxt/app";
41
21
  import { useApi } from "../../composables/useApi";
42
22
  const props = defineProps({
23
+ mode: { type: String, required: false, default: "login" },
43
24
  title: { type: String, required: false, default: "\u0E23\u0E2B\u0E31\u0E2A\u0E1C\u0E48\u0E32\u0E19\u0E43\u0E2B\u0E21\u0E48" },
44
25
  confirmText: { type: String, required: false, default: "\u0E22\u0E37\u0E19\u0E22\u0E31\u0E19" },
45
26
  loginToken: { type: String, required: false },
46
27
  resetToken: { type: String, required: false },
47
- disabledForceLogout: { type: Boolean, required: false, default: false }
28
+ disabledForceLogout: { type: Boolean, required: false, default: false },
29
+ oldPassword: { type: String, required: false },
30
+ twoFaCode: { type: String, required: false }
48
31
  });
49
32
  const emit = defineEmits(["complete", "close"]);
50
33
  const { $toast } = useNuxtApp();
@@ -64,6 +47,28 @@ watch(isOpen, (open) => {
64
47
  }
65
48
  });
66
49
  const handleSubmit = async () => {
50
+ if (props.mode === "secure") {
51
+ loading.value = true;
52
+ try {
53
+ await api("/me/change-password", {
54
+ method: "POST",
55
+ body: {
56
+ old_password: props.oldPassword,
57
+ new_password: password.value,
58
+ ...props.twoFaCode ? { two_fa_code: props.twoFaCode } : {},
59
+ logout_all: logoutAll.value
60
+ }
61
+ });
62
+ emit("complete", null);
63
+ isOpen.value = false;
64
+ } catch (e) {
65
+ const msg = e?.data?.message?.description || e?.data?.message || "\u0E40\u0E01\u0E34\u0E14\u0E02\u0E49\u0E2D\u0E1C\u0E34\u0E14\u0E1E\u0E25\u0E32\u0E14\u0E43\u0E19\u0E01\u0E32\u0E23\u0E40\u0E0A\u0E37\u0E48\u0E2D\u0E21\u0E15\u0E48\u0E2D";
66
+ $toast?.error?.(msg);
67
+ } finally {
68
+ loading.value = false;
69
+ }
70
+ return;
71
+ }
67
72
  if (props.resetToken) {
68
73
  loading.value = true;
69
74
  try {
@@ -84,10 +89,12 @@ const handleSubmit = async () => {
84
89
  loading.value = false;
85
90
  }
86
91
  return;
87
- }
88
- if (!props.loginToken) {
92
+ } else if (!props.loginToken) {
89
93
  $toast?.error?.("\u0E44\u0E21\u0E48\u0E1E\u0E1A login token");
90
94
  return;
95
+ } else if (!props.oldPassword) {
96
+ $toast?.error?.("\u0E44\u0E21\u0E48\u0E1E\u0E1A \u0E23\u0E2B\u0E31\u0E2A\u0E1C\u0E48\u0E32\u0E19\u0E40\u0E14\u0E34\u0E21");
97
+ return;
91
98
  }
92
99
  loading.value = true;
93
100
  try {
@@ -1,10 +1,13 @@
1
1
  interface Props {
2
+ mode?: "login" | "secure";
2
3
  title?: string;
3
4
  confirmText?: string;
4
5
  loginToken?: string;
5
6
  /** When provided, uses forgot-password reset endpoint instead of password/create */
6
7
  resetToken?: string;
7
8
  disabledForceLogout?: boolean;
9
+ oldPassword?: string;
10
+ twoFaCode?: string;
8
11
  }
9
12
  type __VLS_Props = Props;
10
13
  type __VLS_ModelProps = {
@@ -25,6 +28,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
25
28
  } | null) => any) | undefined;
26
29
  }>, {
27
30
  title: string;
31
+ mode: "login" | "secure";
28
32
  confirmText: string;
29
33
  disabledForceLogout: boolean;
30
34
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -19,6 +19,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
19
19
  complete: (data: {
20
20
  secId: string;
21
21
  resetToken?: string;
22
+ password?: string;
22
23
  }) => any;
23
24
  }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
24
25
  onClose?: (() => any) | undefined;
@@ -26,6 +27,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
26
27
  onComplete?: ((data: {
27
28
  secId: string;
28
29
  resetToken?: string;
30
+ password?: string;
29
31
  }) => any) | undefined;
30
32
  }>, {
31
33
  title: string;
@@ -51,7 +51,7 @@ const handleSubmit = async () => {
51
51
  body: { password: password.value }
52
52
  });
53
53
  if (res.message?.title !== "\u0E2A\u0E33\u0E40\u0E23\u0E47\u0E08") throw "\u0E23\u0E2B\u0E31\u0E2A\u0E1C\u0E48\u0E32\u0E19\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07";
54
- emit("complete", { secId: "", resetToken: res.data?.reset_token });
54
+ emit("complete", { secId: "", resetToken: res.data?.reset_token || res.data?.token || res.reset_token || res.token, password: password.value });
55
55
  isOpen.value = false;
56
56
  } else {
57
57
  if (!props.loginToken) {
@@ -74,7 +74,8 @@ const handleSubmit = async () => {
74
74
  }
75
75
  }
76
76
  } catch (e) {
77
- inputRef.value?.setErrors?.(e?.data?.message.description);
77
+ const errorMsg = typeof e === "string" ? e : e?.data?.message?.description || "\u0E23\u0E2B\u0E31\u0E2A\u0E1C\u0E48\u0E32\u0E19\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07";
78
+ inputRef.value?.setErrors?.(errorMsg);
78
79
  } finally {
79
80
  loading.value = false;
80
81
  }
@@ -19,6 +19,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
19
19
  complete: (data: {
20
20
  secId: string;
21
21
  resetToken?: string;
22
+ password?: string;
22
23
  }) => any;
23
24
  }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
24
25
  onClose?: (() => any) | undefined;
@@ -26,6 +27,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
26
27
  onComplete?: ((data: {
27
28
  secId: string;
28
29
  resetToken?: string;
30
+ password?: string;
29
31
  }) => any) | undefined;
30
32
  }>, {
31
33
  title: string;
@@ -3,8 +3,9 @@
3
3
  mode="secure" @complete="(data) => handleComplete(modal.key, data)"
4
4
  :confirmed-text="isLastStep ? '\u0E22\u0E37\u0E19\u0E22\u0E31\u0E19' : '\u0E16\u0E31\u0E14\u0E44\u0E1B'" @close="isOpen = false" v-model="modalStates[modal.key]"
5
5
  :request-path="modal.key === 'phoneOTP' ? '/otp/phone-request' : void 0"
6
- :verify-path="modal.key === 'phoneOTP' ? '/otp/phone-verify' : void 0"
7
- :reset-token="resetTokenState" />
6
+ :verify-path="modal.key === 'phoneOTP' ? '/otp/phone-verify' : void 0" :reset-token="resetTokenState"
7
+ :old-password="oldPasswordState"
8
+ :two-fa-code="twoFaCodeState" />
8
9
  </template>
9
10
 
10
11
  <script setup>
@@ -31,6 +32,8 @@ const isOpen = defineModel({ type: Boolean, ...{
31
32
  } });
32
33
  const isLastStep = ref(false);
33
34
  const resetTokenState = ref("");
35
+ const oldPasswordState = ref("");
36
+ const twoFaCodeState = ref("");
34
37
  const modals = [
35
38
  { key: "password", component: ModalPasswordVerify },
36
39
  { key: "passwordNew", component: ModalPasswordNew },
@@ -44,8 +47,14 @@ const modalStates = reactive(
44
47
  );
45
48
  const handleComplete = (key, data) => {
46
49
  modalStates[key] = false;
47
- if (data?.resetToken || data?.reset_token) {
48
- resetTokenState.value = data.resetToken || data.reset_token;
50
+ if (data?.resetToken || data?.reset_token || data?.token) {
51
+ resetTokenState.value = data.resetToken || data.reset_token || data.token;
52
+ }
53
+ if (data?.password) {
54
+ oldPasswordState.value = data.password;
55
+ }
56
+ if (data?.code) {
57
+ twoFaCodeState.value = data.code;
49
58
  }
50
59
  if (props.state === "add-phone") {
51
60
  if (key === "password") {
@@ -173,6 +182,8 @@ const onDisabled2FA = async () => {
173
182
  watch(isOpen, (v) => {
174
183
  if (!v) return;
175
184
  resetTokenState.value = "";
185
+ oldPasswordState.value = "";
186
+ twoFaCodeState.value = "";
176
187
  modalStates.password = true;
177
188
  if (["delete-phone", "delete-email"].includes(props.state)) {
178
189
  isLastStep.value = !props.twoFaEnabled;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pukaad-ui-lib",
3
- "version": "1.274.0",
3
+ "version": "1.276.0",
4
4
  "description": "pukaad-ui for MeMSG",
5
5
  "repository": {
6
6
  "type": "git",