Compare commits
28
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9a7769ab6e | ||
|
|
e3c82a322a | ||
|
|
216430ac05 | ||
|
|
29fe982d39 | ||
|
|
608da1614e | ||
|
|
52b4dbc8c6 | ||
|
|
421be5cad8 | ||
|
|
1e621be90c | ||
|
|
79d9cb3cea | ||
|
|
0862692b0e | ||
|
|
97dabbf7f6 | ||
|
|
1ee5b4f9d6 | ||
|
|
514e95969a | ||
|
|
80f4ed45a3 | ||
|
|
875d36488e | ||
|
|
f2fe66263f | ||
|
|
86cbe7f0d6 | ||
|
|
5365304c6f | ||
|
|
8b05825681 | ||
|
|
1f60548020 | ||
|
|
1522e14ffb | ||
|
|
8e6210dc2c | ||
|
|
831d3a16c6 | ||
|
|
829c07efbb | ||
|
|
4e74f7920f | ||
|
|
44579bdcad | ||
|
|
068bd8f083 | ||
|
|
9c4c9635a0 |
+1
-1
@@ -202,7 +202,7 @@ defineExpose({ state, isSubmitDisabled });
|
|||||||
size="sm"
|
size="sm"
|
||||||
type="button"
|
type="button"
|
||||||
:icon="!state.icon ? 'i-lucide-smile-plus' : ''"
|
:icon="!state.icon ? 'i-lucide-smile-plus' : ''"
|
||||||
class="!h-[2.4rem] !w-[2.375rem] absolute top-[1.94rem] !outline-none !rounded-[0.438rem] border-0 ltr:left-px rtl:right-px ltr:!rounded-r-none rtl:!rounded-l-none"
|
class="!h-[2.39rem] !w-[2.375rem] absolute top-px !outline-none !rounded-[0.438rem] border-0 ltr:left-px rtl:right-px ltr:!rounded-r-none rtl:!rounded-l-none"
|
||||||
@click="isEmojiPickerOpen = !isEmojiPickerOpen"
|
@click="isEmojiPickerOpen = !isEmojiPickerOpen"
|
||||||
/>
|
/>
|
||||||
<EmojiInput
|
<EmojiInput
|
||||||
|
|||||||
+2
-2
@@ -82,12 +82,12 @@ const handleSendMessage = template => {
|
|||||||
:placeholder="
|
:placeholder="
|
||||||
t('COMPOSE_NEW_CONVERSATION.FORM.TWILIO_OPTIONS.SEARCH_PLACEHOLDER')
|
t('COMPOSE_NEW_CONVERSATION.FORM.TWILIO_OPTIONS.SEARCH_PLACEHOLDER')
|
||||||
"
|
"
|
||||||
custom-input-class="ltr:pl-10 rtl:pr-10"
|
class="ltr:!pl-8 rtl:!pr-8"
|
||||||
>
|
>
|
||||||
<template #prefix>
|
<template #prefix>
|
||||||
<Icon
|
<Icon
|
||||||
icon="i-lucide-search"
|
icon="i-lucide-search"
|
||||||
class="absolute top-2 size-3.5 ltr:left-3 rtl:right-3"
|
class="absolute top-3 size-3.5 ltr:left-3 rtl:right-3"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</Input>
|
</Input>
|
||||||
|
|||||||
+11
-7
@@ -4,6 +4,7 @@ import { useI18n } from 'vue-i18n';
|
|||||||
import { useMapGetter } from 'dashboard/composables/store';
|
import { useMapGetter } from 'dashboard/composables/store';
|
||||||
|
|
||||||
import Icon from 'dashboard/components-next/icon/Icon.vue';
|
import Icon from 'dashboard/components-next/icon/Icon.vue';
|
||||||
|
import Input from 'dashboard/components-next/input/Input.vue';
|
||||||
import Button from 'dashboard/components-next/button/Button.vue';
|
import Button from 'dashboard/components-next/button/Button.vue';
|
||||||
import WhatsappTemplate from './WhatsappTemplate.vue';
|
import WhatsappTemplate from './WhatsappTemplate.vue';
|
||||||
|
|
||||||
@@ -77,11 +78,7 @@ const handleSendMessage = template => {
|
|||||||
class="absolute top-full mt-1.5 max-h-96 overflow-y-auto ltr:left-0 rtl:right-0 flex flex-col gap-2 p-4 items-center w-[21.875rem] h-auto bg-n-solid-2 border border-n-strong shadow-sm rounded-lg"
|
class="absolute top-full mt-1.5 max-h-96 overflow-y-auto ltr:left-0 rtl:right-0 flex flex-col gap-2 p-4 items-center w-[21.875rem] h-auto bg-n-solid-2 border border-n-strong shadow-sm rounded-lg"
|
||||||
>
|
>
|
||||||
<div class="relative w-full">
|
<div class="relative w-full">
|
||||||
<Icon
|
<Input
|
||||||
icon="i-lucide-search"
|
|
||||||
class="absolute size-3.5 top-2 ltr:left-3 rtl:right-3"
|
|
||||||
/>
|
|
||||||
<input
|
|
||||||
v-model="searchQuery"
|
v-model="searchQuery"
|
||||||
type="search"
|
type="search"
|
||||||
:placeholder="
|
:placeholder="
|
||||||
@@ -89,8 +86,15 @@ const handleSendMessage = template => {
|
|||||||
'COMPOSE_NEW_CONVERSATION.FORM.WHATSAPP_OPTIONS.SEARCH_PLACEHOLDER'
|
'COMPOSE_NEW_CONVERSATION.FORM.WHATSAPP_OPTIONS.SEARCH_PLACEHOLDER'
|
||||||
)
|
)
|
||||||
"
|
"
|
||||||
class="w-full h-8 py-2 ltr:pl-10 rtl:pr-10 ltr:pr-2 rtl:pl-2 text-sm reset-base outline-none border-none rounded-lg bg-n-alpha-black2 dark:bg-n-solid-1 text-n-slate-12"
|
class="ltr:!pl-8 rtl:!pr-8"
|
||||||
/>
|
>
|
||||||
|
<template #prefix>
|
||||||
|
<Icon
|
||||||
|
icon="i-lucide-search"
|
||||||
|
class="absolute top-3 size-3.5 ltr:left-3 rtl:right-3"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</Input>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-for="template in filteredTemplates"
|
v-for="template in filteredTemplates"
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { computed, ref, onMounted, nextTick, getCurrentInstance } from 'vue';
|
import { computed, ref, onMounted, nextTick, getCurrentInstance } from 'vue';
|
||||||
|
import { useToggle } from '@vueuse/core';
|
||||||
|
import Button from 'dashboard/components-next/button/Button.vue';
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
modelValue: { type: [String, Number], default: '' },
|
modelValue: { type: [String, Number], default: '' },
|
||||||
type: { type: String, default: 'text' },
|
type: { type: String, default: 'text' },
|
||||||
@@ -17,10 +20,10 @@ const props = defineProps({
|
|||||||
messageType: {
|
messageType: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'info',
|
default: 'info',
|
||||||
validator: value => ['info', 'error', 'success'].includes(value),
|
validator: value => !value || ['info', 'error', 'success'].includes(value),
|
||||||
},
|
},
|
||||||
min: { type: String, default: '' },
|
min: { type: [String, Number], default: '' },
|
||||||
max: { type: String, default: '' },
|
max: { type: [String, Number], default: '' },
|
||||||
autofocus: { type: Boolean, default: false },
|
autofocus: { type: Boolean, default: false },
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -32,6 +35,10 @@ const emit = defineEmits([
|
|||||||
'enter',
|
'enter',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
defineOptions({
|
||||||
|
inheritAttrs: false,
|
||||||
|
});
|
||||||
|
|
||||||
// Generate a unique ID per component instance when `id` prop is not provided.
|
// Generate a unique ID per component instance when `id` prop is not provided.
|
||||||
const { uid } = getCurrentInstance();
|
const { uid } = getCurrentInstance();
|
||||||
const uniqueId = computed(() => props.id || `input-${uid}`);
|
const uniqueId = computed(() => props.id || `input-${uid}`);
|
||||||
@@ -39,25 +46,42 @@ const uniqueId = computed(() => props.id || `input-${uid}`);
|
|||||||
const isFocused = ref(false);
|
const isFocused = ref(false);
|
||||||
const inputRef = ref(null);
|
const inputRef = ref(null);
|
||||||
|
|
||||||
const messageClass = computed(() => {
|
const FIELDS = {
|
||||||
switch (props.messageType) {
|
TEXT: 'text',
|
||||||
case 'error':
|
PASSWORD: 'password',
|
||||||
return 'text-n-ruby-9 dark:text-n-ruby-9';
|
};
|
||||||
case 'success':
|
|
||||||
return 'text-n-teal-10 dark:text-n-teal-10';
|
const [isPasswordVisible, togglePasswordVisibility] = useToggle();
|
||||||
default:
|
|
||||||
return 'text-n-slate-11 dark:text-n-slate-11';
|
const isPasswordField = computed(() => props.type === FIELDS.PASSWORD);
|
||||||
|
|
||||||
|
const currentInputType = computed(() => {
|
||||||
|
if (isPasswordField.value) {
|
||||||
|
return isPasswordVisible.value ? FIELDS.TEXT : FIELDS.PASSWORD;
|
||||||
}
|
}
|
||||||
|
return props.type;
|
||||||
});
|
});
|
||||||
|
|
||||||
const inputOutlineClass = computed(() => {
|
const MESSAGE_STYLES = {
|
||||||
switch (props.messageType) {
|
error: 'text-n-ruby-9 dark:text-n-ruby-9',
|
||||||
case 'error':
|
success: 'text-n-teal-10 dark:text-n-teal-10',
|
||||||
return 'outline-n-ruby-8 dark:outline-n-ruby-8 hover:outline-n-ruby-9 dark:hover:outline-n-ruby-9 disabled:outline-n-ruby-8 dark:disabled:outline-n-ruby-8';
|
info: 'text-n-slate-11 dark:text-n-slate-11',
|
||||||
default:
|
};
|
||||||
return 'outline-n-weak dark:outline-n-weak hover:outline-n-slate-6 dark:hover:outline-n-slate-6 disabled:outline-n-weak dark:disabled:outline-n-weak focus:outline-n-brand dark:focus:outline-n-brand';
|
|
||||||
}
|
const OUTLINE_STYLES = {
|
||||||
});
|
error:
|
||||||
|
'outline-n-ruby-8 dark:outline-n-ruby-8 hover:outline-n-ruby-9 dark:hover:outline-n-ruby-9 disabled:outline-n-ruby-8 dark:disabled:outline-n-ruby-8',
|
||||||
|
default:
|
||||||
|
'outline-n-weak dark:outline-n-weak hover:outline-n-slate-6 dark:hover:outline-n-slate-6 disabled:outline-n-weak dark:disabled:outline-n-weak focus:outline-n-brand dark:focus:outline-n-brand',
|
||||||
|
};
|
||||||
|
|
||||||
|
const messageClass = computed(
|
||||||
|
() => MESSAGE_STYLES[props.messageType || 'info'] || MESSAGE_STYLES.info
|
||||||
|
);
|
||||||
|
|
||||||
|
const inputOutlineClass = computed(
|
||||||
|
() => OUTLINE_STYLES[props.messageType || 'info'] || OUTLINE_STYLES.default
|
||||||
|
);
|
||||||
|
|
||||||
const handleInput = event => {
|
const handleInput = event => {
|
||||||
let value = event.target.value;
|
let value = event.target.value;
|
||||||
@@ -104,7 +128,7 @@ onMounted(() => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="relative flex flex-col min-w-0 gap-1">
|
<div class="relative flex flex-col min-w-0 gap-1 w-full">
|
||||||
<label
|
<label
|
||||||
v-if="label"
|
v-if="label"
|
||||||
:for="uniqueId"
|
:for="uniqueId"
|
||||||
@@ -112,40 +136,57 @@ onMounted(() => {
|
|||||||
>
|
>
|
||||||
{{ label }}
|
{{ label }}
|
||||||
</label>
|
</label>
|
||||||
<!-- Added prefix slot to allow adding icons to the input -->
|
<div class="relative flex min-w-0 items-center">
|
||||||
<slot name="prefix" />
|
<!-- Added prefix slot to allow adding icons to the input -->
|
||||||
<input
|
<slot name="prefix" />
|
||||||
:id="uniqueId"
|
<input
|
||||||
v-bind="$attrs"
|
:id="uniqueId"
|
||||||
ref="inputRef"
|
ref="inputRef"
|
||||||
:value="modelValue"
|
v-bind="$attrs"
|
||||||
:class="[
|
:value="modelValue"
|
||||||
customInputClass,
|
:class="[
|
||||||
inputOutlineClass,
|
customInputClass,
|
||||||
sizeClass,
|
inputOutlineClass,
|
||||||
{
|
sizeClass,
|
||||||
error: messageType === 'error',
|
{
|
||||||
focus: isFocused,
|
error: messageType === 'error',
|
||||||
},
|
focus: isFocused,
|
||||||
]"
|
'ltr:!pr-10 rtl:!pl-10': isPasswordField,
|
||||||
:type="type"
|
},
|
||||||
:placeholder="placeholder"
|
]"
|
||||||
:disabled="disabled"
|
:type="currentInputType"
|
||||||
:min="['date', 'datetime-local', 'time'].includes(type) ? min : undefined"
|
:placeholder="placeholder"
|
||||||
:max="
|
:disabled="disabled"
|
||||||
['date', 'datetime-local', 'time', 'number'].includes(type)
|
:min="
|
||||||
? max
|
['date', 'datetime-local', 'time'].includes(type) ? min : undefined
|
||||||
: undefined
|
"
|
||||||
"
|
:max="
|
||||||
class="block w-full reset-base text-sm !mb-0 outline outline-1 border-none border-0 outline-offset-[-1px] rounded-lg bg-n-alpha-black2 file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-n-slate-10 dark:placeholder:text-n-slate-10 disabled:cursor-not-allowed disabled:opacity-50 text-n-slate-12 transition-all duration-500 ease-in-out [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none"
|
['date', 'datetime-local', 'time', 'number'].includes(type)
|
||||||
@input="handleInput"
|
? max
|
||||||
@focus="handleFocus"
|
: undefined
|
||||||
@blur="handleBlur"
|
"
|
||||||
@keyup.enter="handleEnter"
|
class="block w-full reset-base text-sm !mb-0 outline outline-1 border-none border-0 outline-offset-[-1px] rounded-lg bg-n-alpha-black2 file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-n-slate-10 dark:placeholder:text-n-slate-10 disabled:cursor-not-allowed disabled:opacity-50 text-n-slate-12 transition-all duration-500 ease-in-out [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none"
|
||||||
/>
|
@input="handleInput"
|
||||||
|
@focus="handleFocus"
|
||||||
|
@blur="handleBlur"
|
||||||
|
@keyup.enter="handleEnter"
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
v-if="isPasswordField"
|
||||||
|
type="button"
|
||||||
|
slate
|
||||||
|
sm
|
||||||
|
link
|
||||||
|
class="absolute inset-y-0 ltr:right-3.5 rtl:left-3.5"
|
||||||
|
:icon="isPasswordVisible ? 'i-lucide-eye-off' : 'i-lucide-eye'"
|
||||||
|
:aria-label="isPasswordVisible ? 'Hide password' : 'Show password'"
|
||||||
|
:aria-pressed="isPasswordVisible"
|
||||||
|
@click="togglePasswordVisibility()"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
<p
|
<p
|
||||||
v-if="message"
|
v-if="message"
|
||||||
class="min-w-0 mt-1 mb-0 text-xs truncate transition-all duration-500 ease-in-out"
|
class="min-w-0 mt-0.5 mb-0 text-xs truncate transition-all duration-500 ease-in-out"
|
||||||
:class="messageClass"
|
:class="messageClass"
|
||||||
>
|
>
|
||||||
{{ message }}
|
{{ message }}
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ watch(
|
|||||||
<div>
|
<div>
|
||||||
<div
|
<div
|
||||||
v-on-clickaway="() => closeCountryDropdown()"
|
v-on-clickaway="() => closeCountryDropdown()"
|
||||||
class="relative flex items-center h-8 transition-all duration-500 ease-in-out outline outline-1 outline-offset-[-1px] rounded-lg bg-n-alpha-black2"
|
class="relative flex items-center h-8 transition-all duration-500 ease-in-out outline outline-1 outline-offset-[-1px] w-full rounded-lg bg-n-alpha-black2"
|
||||||
:class="[inputBorderClass, { 'cursor-not-allowed opacity-50': disabled }]"
|
:class="[inputBorderClass, { 'cursor-not-allowed opacity-50': disabled }]"
|
||||||
>
|
>
|
||||||
<Input
|
<Input
|
||||||
@@ -171,8 +171,7 @@ watch(
|
|||||||
type="tel"
|
type="tel"
|
||||||
:placeholder="placeholder"
|
:placeholder="placeholder"
|
||||||
:disabled="disabled"
|
:disabled="disabled"
|
||||||
custom-input-class="!border-0 !outline-none h-8 !py-0.5 !bg-transparent ltr:!pl-1 rtl:!pr-1"
|
class="!border-0 !outline-none h-8 !py-0.5 !bg-transparent ltr:!pl-1 rtl:!pr-1"
|
||||||
class="w-full !flex-row"
|
|
||||||
>
|
>
|
||||||
<template #prefix>
|
<template #prefix>
|
||||||
<div class="flex items-center flex-shrink-0">
|
<div class="flex items-center flex-shrink-0">
|
||||||
@@ -186,7 +185,7 @@ watch(
|
|||||||
trailing-icon
|
trailing-icon
|
||||||
:disabled="disabled"
|
:disabled="disabled"
|
||||||
type="button"
|
type="button"
|
||||||
class="!h-[1.875rem] top-1 ltr:ml-px rtl:mr-px !px-2 outline-0 !outline-none !rounded-lg border-0 ltr:!rounded-r-none rtl:!rounded-l-none"
|
class="!h-[1.875rem] top-1 ltr:ml-px rtl:mr-px !px-2 outline-0 !outline-none !rounded-[7px] border-0 ltr:!rounded-r-none rtl:!rounded-l-none"
|
||||||
@click="toggleCountryDropdown"
|
@click="toggleCountryDropdown"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { parseAPIErrorResponse } from 'dashboard/store/utils/api';
|
|||||||
import { useAccount } from 'dashboard/composables/useAccount';
|
import { useAccount } from 'dashboard/composables/useAccount';
|
||||||
|
|
||||||
import Icon from 'dashboard/components-next/icon/Icon.vue';
|
import Icon from 'dashboard/components-next/icon/Icon.vue';
|
||||||
import FormInput from 'v3/components/Form/Input.vue';
|
import FormInput from 'dashboard/components-next/input/Input.vue';
|
||||||
import NextButton from 'dashboard/components-next/button/Button.vue';
|
import NextButton from 'dashboard/components-next/button/Button.vue';
|
||||||
import Dialog from 'dashboard/components-next/dialog/Dialog.vue';
|
import Dialog from 'dashboard/components-next/dialog/Dialog.vue';
|
||||||
|
|
||||||
@@ -200,7 +200,7 @@ const handleTryAnotherMethod = () => {
|
|||||||
<form class="space-y-4" @submit.prevent="handleVerification">
|
<form class="space-y-4" @submit.prevent="handleVerification">
|
||||||
<!-- OTP Code Input -->
|
<!-- OTP Code Input -->
|
||||||
<div v-if="verificationMethod === OTP">
|
<div v-if="verificationMethod === OTP">
|
||||||
<label class="block text-sm font-medium text-n-slate-12 mb-2">
|
<label class="block text-sm font-medium text-n-slate-12 mb-1.5">
|
||||||
{{ $t('MFA_VERIFICATION.ENTER_OTP_CODE') }}
|
{{ $t('MFA_VERIFICATION.ENTER_OTP_CODE') }}
|
||||||
</label>
|
</label>
|
||||||
<div class="flex justify-between gap-2">
|
<div class="flex justify-between gap-2">
|
||||||
@@ -213,7 +213,7 @@ const handleTryAnotherMethod = () => {
|
|||||||
maxlength="1"
|
maxlength="1"
|
||||||
pattern="[0-9]"
|
pattern="[0-9]"
|
||||||
inputmode="numeric"
|
inputmode="numeric"
|
||||||
class="w-12 h-12 text-center text-lg font-semibold border-2 border-n-weak hover:border-n-strong rounded-lg focus:border-n-brand bg-n-alpha-black2 text-n-slate-12 placeholder:text-n-slate-10"
|
class="w-12 h-10 text-center text-lg font-semibold outline outline-1 outline-n-weak hover:outline-n-slate-6 rounded-lg focus:outline-n-brand bg-n-alpha-black2 text-n-slate-12 placeholder:text-n-slate-10"
|
||||||
@input="handleOtpInput(i)"
|
@input="handleOtpInput(i)"
|
||||||
@keydown.left.prevent="focusInput(i - 1)"
|
@keydown.left.prevent="focusInput(i - 1)"
|
||||||
@keydown.right.prevent="focusInput(i + 1)"
|
@keydown.right.prevent="focusInput(i + 1)"
|
||||||
@@ -229,6 +229,7 @@ const handleTryAnotherMethod = () => {
|
|||||||
v-model="backupCode"
|
v-model="backupCode"
|
||||||
name="backup_code"
|
name="backup_code"
|
||||||
type="text"
|
type="text"
|
||||||
|
autocomplete="one-time-code"
|
||||||
data-testid="backup_code_input"
|
data-testid="backup_code_input"
|
||||||
:tabindex="1"
|
:tabindex="1"
|
||||||
required
|
required
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script>
|
<script>
|
||||||
import validations from './helpers/validations';
|
import validations from './helpers/validations';
|
||||||
import FormInput from 'v3/components/Form/Input.vue';
|
import FormInput from 'dashboard/components-next/input/Input.vue';
|
||||||
import { reactive } from 'vue';
|
import { reactive } from 'vue';
|
||||||
import { useVuelidate } from '@vuelidate/core';
|
import { useVuelidate } from '@vuelidate/core';
|
||||||
|
|
||||||
@@ -69,21 +69,19 @@ export default {
|
|||||||
<FormInput
|
<FormInput
|
||||||
v-model="state.title"
|
v-model="state.title"
|
||||||
name="title"
|
name="title"
|
||||||
spacing="compact"
|
|
||||||
:label="$t('TEAMS_SETTINGS.FORM.NAME.LABEL')"
|
:label="$t('TEAMS_SETTINGS.FORM.NAME.LABEL')"
|
||||||
:placeholder="$t('TEAMS_SETTINGS.FORM.NAME.PLACEHOLDER')"
|
:placeholder="$t('TEAMS_SETTINGS.FORM.NAME.PLACEHOLDER')"
|
||||||
:has-error="v$.title.$error"
|
:message-type="v$.title.$error ? 'error' : ''"
|
||||||
:error-message="v$.title.$error ? v$.title.$errors[0].$message : ''"
|
:message="v$.title.$error ? v$.title.$errors[0].$message : ''"
|
||||||
@blur="v$.title.$touch"
|
@blur="v$.title.$touch"
|
||||||
/>
|
/>
|
||||||
<FormInput
|
<FormInput
|
||||||
v-model="state.description"
|
v-model="state.description"
|
||||||
name="description"
|
name="description"
|
||||||
spacing="compact"
|
|
||||||
:label="$t('TEAMS_SETTINGS.FORM.DESCRIPTION.LABEL')"
|
:label="$t('TEAMS_SETTINGS.FORM.DESCRIPTION.LABEL')"
|
||||||
:placeholder="$t('TEAMS_SETTINGS.FORM.DESCRIPTION.PLACEHOLDER')"
|
:placeholder="$t('TEAMS_SETTINGS.FORM.DESCRIPTION.PLACEHOLDER')"
|
||||||
:has-error="v$.description.$error"
|
:message-type="v$.description.$error ? 'error' : ''"
|
||||||
:error-message="
|
:message="
|
||||||
v$.description.$error ? v$.description.$errors[0].$message : ''
|
v$.description.$error ? v$.description.$errors[0].$message : ''
|
||||||
"
|
"
|
||||||
@blur="v$.description.$touch"
|
@blur="v$.description.$touch"
|
||||||
|
|||||||
+41
-38
@@ -1,48 +1,51 @@
|
|||||||
<script>
|
<script setup>
|
||||||
|
import { ref, onMounted, getCurrentInstance } from 'vue';
|
||||||
import SnackbarContainer from './components/SnackBar/Container.vue';
|
import SnackbarContainer from './components/SnackBar/Container.vue';
|
||||||
|
|
||||||
export default {
|
const theme = ref('light');
|
||||||
components: { SnackbarContainer },
|
|
||||||
data() {
|
|
||||||
return { theme: 'light' };
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.setColorTheme();
|
|
||||||
this.listenToThemeChanges();
|
|
||||||
this.setLocale(window.chatwootConfig.selectedLocale);
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
setColorTheme() {
|
|
||||||
if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
|
||||||
this.theme = 'dark';
|
|
||||||
document.documentElement.classList.add('dark');
|
|
||||||
} else {
|
|
||||||
this.theme = 'light';
|
|
||||||
document.documentElement.classList.remove('dark');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
listenToThemeChanges() {
|
|
||||||
const mql = window.matchMedia('(prefers-color-scheme: dark)');
|
|
||||||
|
|
||||||
mql.onchange = e => {
|
const setColorTheme = () => {
|
||||||
if (e.matches) {
|
if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
||||||
this.theme = 'dark';
|
theme.value = 'dark';
|
||||||
document.documentElement.classList.add('dark');
|
document.documentElement.classList.add('dark');
|
||||||
} else {
|
} else {
|
||||||
this.theme = 'light';
|
theme.value = 'light';
|
||||||
document.documentElement.classList.remove('dark');
|
document.documentElement.classList.remove('dark');
|
||||||
}
|
}
|
||||||
};
|
|
||||||
},
|
|
||||||
setLocale(locale) {
|
|
||||||
this.$root.$i18n.locale = locale;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const listenToThemeChanges = () => {
|
||||||
|
const mql = window.matchMedia('(prefers-color-scheme: dark)');
|
||||||
|
|
||||||
|
mql.onchange = e => {
|
||||||
|
if (e.matches) {
|
||||||
|
theme.value = 'dark';
|
||||||
|
document.documentElement.classList.add('dark');
|
||||||
|
} else {
|
||||||
|
theme.value = 'light';
|
||||||
|
document.documentElement.classList.remove('dark');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const setLocale = locale => {
|
||||||
|
const instance = getCurrentInstance();
|
||||||
|
if (instance) {
|
||||||
|
instance.appContext.config.globalProperties.$i18n.locale = locale;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
// Add background color class once - it automatically handles light/dark modes
|
||||||
|
document.documentElement.classList.add('bg-n-background');
|
||||||
|
setColorTheme();
|
||||||
|
listenToThemeChanges();
|
||||||
|
setLocale(window.chatwootConfig.selectedLocale);
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="h-full min-h-screen w-full antialiased" :class="theme">
|
<div class="h-full min-h-screen w-full antialiased" dir="ltr" :class="theme">
|
||||||
<router-view />
|
<router-view />
|
||||||
<SnackbarContainer />
|
<SnackbarContainer />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ export default {
|
|||||||
<div class="flex flex-col">
|
<div class="flex flex-col">
|
||||||
<a
|
<a
|
||||||
:href="getGoogleAuthUrl()"
|
:href="getGoogleAuthUrl()"
|
||||||
class="inline-flex justify-center w-full px-4 py-3 bg-n-background dark:bg-n-solid-3 items-center rounded-md shadow-sm ring-1 ring-inset ring-n-container dark:ring-n-container focus:outline-offset-0 hover:bg-n-alpha-2 dark:hover:bg-n-alpha-2"
|
class="inline-flex justify-center w-full px-4 py-3 items-center bg-n-background dark:bg-n-solid-3 rounded-lg shadow-sm ring-1 ring-inset ring-n-container dark:ring-n-container focus:outline-offset-0 hover:bg-n-alpha-2 dark:hover:bg-n-alpha-2"
|
||||||
>
|
>
|
||||||
<span class="i-logos-google-icon h-6" />
|
<span class="i-logos-google-icon h-6" />
|
||||||
<span class="ml-2 text-base font-medium text-n-slate-12">
|
<span class="ml-2 text-base font-medium text-n-slate-12">
|
||||||
|
|||||||
@@ -1,32 +1,30 @@
|
|||||||
<script>
|
<script setup>
|
||||||
|
import { onMounted } from 'vue';
|
||||||
import { DEFAULT_REDIRECT_URL } from 'dashboard/constants/globals';
|
import { DEFAULT_REDIRECT_URL } from 'dashboard/constants/globals';
|
||||||
import { verifyPasswordToken } from '../../../api/auth';
|
import { verifyPasswordToken } from '../../../api/auth';
|
||||||
import Spinner from 'shared/components/Spinner.vue';
|
import Spinner from 'shared/components/Spinner.vue';
|
||||||
|
|
||||||
export default {
|
const props = defineProps({
|
||||||
components: { Spinner },
|
confirmationToken: {
|
||||||
props: {
|
type: String,
|
||||||
confirmationToken: {
|
default: '',
|
||||||
type: String,
|
|
||||||
default: '',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.confirmToken();
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
async confirmToken() {
|
|
||||||
try {
|
|
||||||
await verifyPasswordToken({
|
|
||||||
confirmationToken: this.confirmationToken,
|
|
||||||
});
|
|
||||||
window.location = DEFAULT_REDIRECT_URL;
|
|
||||||
} catch (error) {
|
|
||||||
window.location = DEFAULT_REDIRECT_URL;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const confirmToken = async () => {
|
||||||
|
try {
|
||||||
|
await verifyPasswordToken({
|
||||||
|
confirmationToken: props.confirmationToken,
|
||||||
|
});
|
||||||
|
window.location = DEFAULT_REDIRECT_URL;
|
||||||
|
} catch (error) {
|
||||||
|
window.location = DEFAULT_REDIRECT_URL;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
confirmToken();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
@@ -1,88 +1,72 @@
|
|||||||
<script>
|
<script setup>
|
||||||
|
import { ref, reactive, computed, onMounted } from 'vue';
|
||||||
import { useVuelidate } from '@vuelidate/core';
|
import { useVuelidate } from '@vuelidate/core';
|
||||||
import { required, minLength } from '@vuelidate/validators';
|
import { required, minLength } from '@vuelidate/validators';
|
||||||
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useAlert } from 'dashboard/composables';
|
import { useAlert } from 'dashboard/composables';
|
||||||
import FormInput from '../../../components/Form/Input.vue';
|
import Input from 'dashboard/components-next/input/Input.vue';
|
||||||
import NextButton from 'dashboard/components-next/button/Button.vue';
|
import NextButton from 'dashboard/components-next/button/Button.vue';
|
||||||
import { DEFAULT_REDIRECT_URL } from 'dashboard/constants/globals';
|
import { DEFAULT_REDIRECT_URL } from 'dashboard/constants/globals';
|
||||||
import { setNewPassword } from '../../../api/auth';
|
import { setNewPassword } from '../../../api/auth';
|
||||||
|
|
||||||
export default {
|
const props = defineProps({
|
||||||
components: {
|
resetPasswordToken: { type: String, default: '' },
|
||||||
FormInput,
|
});
|
||||||
NextButton,
|
|
||||||
},
|
const { t } = useI18n();
|
||||||
props: {
|
|
||||||
resetPasswordToken: { type: String, default: '' },
|
const credentials = reactive({
|
||||||
},
|
confirmPassword: '',
|
||||||
setup() {
|
password: '',
|
||||||
return { v$: useVuelidate() };
|
});
|
||||||
},
|
|
||||||
data() {
|
const showLoading = ref(false);
|
||||||
return {
|
|
||||||
// We need to initialize the component with any
|
const rules = computed(() => ({
|
||||||
// properties that will be used in it
|
credentials: {
|
||||||
credentials: {
|
password: {
|
||||||
confirmPassword: '',
|
required,
|
||||||
password: '',
|
minLength: minLength(6),
|
||||||
},
|
},
|
||||||
newPasswordAPI: {
|
confirmPassword: {
|
||||||
message: '',
|
required,
|
||||||
showLoading: false,
|
minLength: minLength(6),
|
||||||
},
|
isEqPassword(value) {
|
||||||
error: '',
|
return value === credentials.password;
|
||||||
};
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
// If url opened without token
|
|
||||||
// redirect to login
|
|
||||||
if (!this.resetPasswordToken) {
|
|
||||||
window.location = DEFAULT_REDIRECT_URL;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
validations: {
|
|
||||||
credentials: {
|
|
||||||
password: {
|
|
||||||
required,
|
|
||||||
minLength: minLength(6),
|
|
||||||
},
|
|
||||||
confirmPassword: {
|
|
||||||
required,
|
|
||||||
minLength: minLength(6),
|
|
||||||
isEqPassword(value) {
|
|
||||||
if (value !== this.credentials.password) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
}));
|
||||||
showAlertMessage(message) {
|
|
||||||
// Reset loading, current selected agent
|
const v$ = useVuelidate(rules, { credentials });
|
||||||
this.newPasswordAPI.showLoading = false;
|
|
||||||
useAlert(message);
|
const showAlertMessage = message => {
|
||||||
},
|
showLoading.value = false;
|
||||||
submitForm() {
|
useAlert(message);
|
||||||
this.newPasswordAPI.showLoading = true;
|
|
||||||
const credentials = {
|
|
||||||
confirmPassword: this.credentials.confirmPassword,
|
|
||||||
password: this.credentials.password,
|
|
||||||
resetPasswordToken: this.resetPasswordToken,
|
|
||||||
};
|
|
||||||
setNewPassword(credentials)
|
|
||||||
.then(() => {
|
|
||||||
window.location = DEFAULT_REDIRECT_URL;
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
this.showAlertMessage(
|
|
||||||
error?.message || this.$t('SET_NEW_PASSWORD.API.ERROR_MESSAGE')
|
|
||||||
);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const submitForm = async () => {
|
||||||
|
showLoading.value = true;
|
||||||
|
const credentialsData = {
|
||||||
|
confirmPassword: credentials.confirmPassword,
|
||||||
|
password: credentials.password,
|
||||||
|
resetPasswordToken: props.resetPasswordToken,
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
await setNewPassword(credentialsData);
|
||||||
|
window.location = DEFAULT_REDIRECT_URL;
|
||||||
|
} catch (error) {
|
||||||
|
showAlertMessage(error?.message || t('SET_NEW_PASSWORD.API.ERROR_MESSAGE'));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
// If url opened without token, redirect to login
|
||||||
|
if (!props.resetPasswordToken) {
|
||||||
|
window.location = DEFAULT_REDIRECT_URL;
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -99,24 +83,32 @@ export default {
|
|||||||
{{ $t('SET_NEW_PASSWORD.TITLE') }}
|
{{ $t('SET_NEW_PASSWORD.TITLE') }}
|
||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
<div class="space-y-5">
|
<div class="space-y-6 mt-5">
|
||||||
<FormInput
|
<Input
|
||||||
v-model="credentials.password"
|
v-model="credentials.password"
|
||||||
class="mt-3"
|
|
||||||
name="password"
|
name="password"
|
||||||
type="password"
|
type="password"
|
||||||
:has-error="v$.credentials.password.$error"
|
autocomplete="new-password"
|
||||||
:error-message="$t('SET_NEW_PASSWORD.PASSWORD.ERROR')"
|
:message-type="v$.credentials.password.$error ? 'error' : ''"
|
||||||
|
:message="
|
||||||
|
v$.credentials.password.$error
|
||||||
|
? $t('SET_NEW_PASSWORD.PASSWORD.ERROR')
|
||||||
|
: ''
|
||||||
|
"
|
||||||
:placeholder="$t('SET_NEW_PASSWORD.PASSWORD.PLACEHOLDER')"
|
:placeholder="$t('SET_NEW_PASSWORD.PASSWORD.PLACEHOLDER')"
|
||||||
@blur="v$.credentials.password.$touch"
|
@blur="v$.credentials.password.$touch"
|
||||||
/>
|
/>
|
||||||
<FormInput
|
<Input
|
||||||
v-model="credentials.confirmPassword"
|
v-model="credentials.confirmPassword"
|
||||||
class="mt-3"
|
|
||||||
name="confirm_password"
|
name="confirm_password"
|
||||||
type="password"
|
type="password"
|
||||||
:has-error="v$.credentials.confirmPassword.$error"
|
autocomplete="confirm-password"
|
||||||
:error-message="$t('SET_NEW_PASSWORD.CONFIRM_PASSWORD.ERROR')"
|
:message-type="v$.credentials.confirmPassword.$error ? 'error' : ''"
|
||||||
|
:message="
|
||||||
|
v$.credentials.confirmPassword.$error
|
||||||
|
? $t('SET_NEW_PASSWORD.CONFIRM_PASSWORD.ERROR')
|
||||||
|
: ''
|
||||||
|
"
|
||||||
:placeholder="$t('SET_NEW_PASSWORD.CONFIRM_PASSWORD.PLACEHOLDER')"
|
:placeholder="$t('SET_NEW_PASSWORD.CONFIRM_PASSWORD.PLACEHOLDER')"
|
||||||
@blur="v$.credentials.confirmPassword.$touch"
|
@blur="v$.credentials.confirmPassword.$touch"
|
||||||
/>
|
/>
|
||||||
@@ -129,9 +121,9 @@ export default {
|
|||||||
:disabled="
|
:disabled="
|
||||||
v$.credentials.password.$invalid ||
|
v$.credentials.password.$invalid ||
|
||||||
v$.credentials.confirmPassword.$invalid ||
|
v$.credentials.confirmPassword.$invalid ||
|
||||||
newPasswordAPI.showLoading
|
showLoading
|
||||||
"
|
"
|
||||||
:is-loading="newPasswordAPI.showLoading"
|
:is-loading="showLoading"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -1,64 +1,54 @@
|
|||||||
<script>
|
<script setup>
|
||||||
|
import { ref, reactive, computed } from 'vue';
|
||||||
import { useVuelidate } from '@vuelidate/core';
|
import { useVuelidate } from '@vuelidate/core';
|
||||||
import { useAlert } from 'dashboard/composables';
|
|
||||||
import { required, minLength, email } from '@vuelidate/validators';
|
import { required, minLength, email } from '@vuelidate/validators';
|
||||||
|
import { useI18n } from 'vue-i18n';
|
||||||
|
import { useAlert } from 'dashboard/composables';
|
||||||
import { useBranding } from 'shared/composables/useBranding';
|
import { useBranding } from 'shared/composables/useBranding';
|
||||||
import FormInput from '../../../../components/Form/Input.vue';
|
|
||||||
import { resetPassword } from '../../../../api/auth';
|
import { resetPassword } from '../../../../api/auth';
|
||||||
|
import Input from 'dashboard/components-next/input/Input.vue';
|
||||||
import NextButton from 'dashboard/components-next/button/Button.vue';
|
import NextButton from 'dashboard/components-next/button/Button.vue';
|
||||||
|
|
||||||
export default {
|
const { t } = useI18n();
|
||||||
components: { FormInput, NextButton },
|
const { replaceInstallationName } = useBranding();
|
||||||
setup() {
|
|
||||||
const { replaceInstallationName } = useBranding();
|
const credentials = reactive({ email: '' });
|
||||||
return { v$: useVuelidate(), replaceInstallationName };
|
const showLoading = ref(false);
|
||||||
},
|
|
||||||
data() {
|
const rules = computed(() => ({
|
||||||
return {
|
credentials: {
|
||||||
credentials: { email: '' },
|
email: {
|
||||||
resetPassword: {
|
required,
|
||||||
message: '',
|
email,
|
||||||
showLoading: false,
|
minLength: minLength(4),
|
||||||
},
|
|
||||||
error: '',
|
|
||||||
};
|
|
||||||
},
|
|
||||||
validations() {
|
|
||||||
return {
|
|
||||||
credentials: {
|
|
||||||
email: {
|
|
||||||
required,
|
|
||||||
email,
|
|
||||||
minLength: minLength(4),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
showAlertMessage(message) {
|
|
||||||
// Reset loading, current selected agent
|
|
||||||
this.resetPassword.showLoading = false;
|
|
||||||
useAlert(message);
|
|
||||||
},
|
|
||||||
submit() {
|
|
||||||
this.resetPassword.showLoading = true;
|
|
||||||
resetPassword(this.credentials)
|
|
||||||
.then(res => {
|
|
||||||
let successMessage = this.$t('RESET_PASSWORD.API.SUCCESS_MESSAGE');
|
|
||||||
if (res.data && res.data.message) {
|
|
||||||
successMessage = res.data.message;
|
|
||||||
}
|
|
||||||
this.showAlertMessage(successMessage);
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
let errorMessage = this.$t('RESET_PASSWORD.API.ERROR_MESSAGE');
|
|
||||||
if (error?.response?.data?.message) {
|
|
||||||
errorMessage = error.response.data.message;
|
|
||||||
}
|
|
||||||
this.showAlertMessage(errorMessage);
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
const v$ = useVuelidate(rules, { credentials });
|
||||||
|
|
||||||
|
const showAlertMessage = message => {
|
||||||
|
showLoading.value = false;
|
||||||
|
useAlert(message);
|
||||||
|
};
|
||||||
|
|
||||||
|
const submit = async () => {
|
||||||
|
showLoading.value = true;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const res = await resetPassword(credentials);
|
||||||
|
let successMessage = t('RESET_PASSWORD.API.SUCCESS_MESSAGE');
|
||||||
|
if (res.data && res.data.message) {
|
||||||
|
successMessage = res.data.message;
|
||||||
|
}
|
||||||
|
showAlertMessage(successMessage);
|
||||||
|
} catch (error) {
|
||||||
|
let errorMessage = t('RESET_PASSWORD.API.ERROR_MESSAGE');
|
||||||
|
if (error?.response?.data?.message) {
|
||||||
|
errorMessage = error.response.data.message;
|
||||||
|
}
|
||||||
|
showAlertMessage(errorMessage);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -81,11 +71,15 @@ export default {
|
|||||||
{{ replaceInstallationName($t('RESET_PASSWORD.DESCRIPTION')) }}
|
{{ replaceInstallationName($t('RESET_PASSWORD.DESCRIPTION')) }}
|
||||||
</p>
|
</p>
|
||||||
<div class="space-y-5">
|
<div class="space-y-5">
|
||||||
<FormInput
|
<Input
|
||||||
v-model="credentials.email"
|
v-model="credentials.email"
|
||||||
name="email_address"
|
name="email_address"
|
||||||
:has-error="v$.credentials.email.$error"
|
autocomplete="email"
|
||||||
:error-message="$t('RESET_PASSWORD.EMAIL.ERROR')"
|
type="email"
|
||||||
|
:message="
|
||||||
|
v$.credentials.email.$error ? $t('RESET_PASSWORD.EMAIL.ERROR') : ''
|
||||||
|
"
|
||||||
|
:message-type="v$.credentials.email.$error ? 'error' : ''"
|
||||||
:placeholder="$t('RESET_PASSWORD.EMAIL.PLACEHOLDER')"
|
:placeholder="$t('RESET_PASSWORD.EMAIL.PLACEHOLDER')"
|
||||||
@input="v$.credentials.email.$touch"
|
@input="v$.credentials.email.$touch"
|
||||||
/>
|
/>
|
||||||
@@ -95,8 +89,8 @@ export default {
|
|||||||
data-testid="submit_button"
|
data-testid="submit_button"
|
||||||
class="w-full"
|
class="w-full"
|
||||||
:label="$t('RESET_PASSWORD.SUBMIT')"
|
:label="$t('RESET_PASSWORD.SUBMIT')"
|
||||||
:disabled="v$.credentials.email.$invalid || resetPassword.showLoading"
|
:disabled="v$.credentials.email.$invalid || showLoading"
|
||||||
:is-loading="resetPassword.showLoading"
|
:is-loading="showLoading"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<p class="mt-4 -mb-1 text-sm text-n-slate-11">
|
<p class="mt-4 -mb-1 text-sm text-n-slate-11">
|
||||||
|
|||||||
@@ -1,38 +1,28 @@
|
|||||||
<script>
|
<script setup>
|
||||||
import { mapGetters } from 'vuex';
|
import { ref, computed, onBeforeMount } from 'vue';
|
||||||
|
import { useMapGetter } from 'dashboard/composables/store';
|
||||||
import { useBranding } from 'shared/composables/useBranding';
|
import { useBranding } from 'shared/composables/useBranding';
|
||||||
import SignupForm from './components/Signup/Form.vue';
|
import SignupForm from './components/Signup/Form.vue';
|
||||||
import Testimonials from './components/Testimonials/Index.vue';
|
import Testimonials from './components/Testimonials/Index.vue';
|
||||||
import Spinner from 'shared/components/Spinner.vue';
|
import Spinner from 'shared/components/Spinner.vue';
|
||||||
|
|
||||||
export default {
|
const { replaceInstallationName } = useBranding();
|
||||||
components: {
|
|
||||||
SignupForm,
|
const globalConfig = useMapGetter('globalConfig/get');
|
||||||
Spinner,
|
|
||||||
Testimonials,
|
const isLoading = ref(false);
|
||||||
},
|
|
||||||
setup() {
|
const isAChatwootInstance = computed(() => {
|
||||||
const { replaceInstallationName } = useBranding();
|
return globalConfig.value.installationName === 'Chatwoot';
|
||||||
return { replaceInstallationName };
|
});
|
||||||
},
|
|
||||||
data() {
|
const resizeContainers = () => {
|
||||||
return { isLoading: false };
|
isLoading.value = false;
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
...mapGetters({ globalConfig: 'globalConfig/get' }),
|
|
||||||
isAChatwootInstance() {
|
|
||||||
return this.globalConfig.installationName === 'Chatwoot';
|
|
||||||
},
|
|
||||||
},
|
|
||||||
beforeMount() {
|
|
||||||
this.isLoading = this.isAChatwootInstance;
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
resizeContainers() {
|
|
||||||
this.isLoading = false;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
onBeforeMount(() => {
|
||||||
|
isLoading.value = isAChatwootInstance.value;
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -62,8 +52,8 @@ export default {
|
|||||||
</div>
|
</div>
|
||||||
<SignupForm />
|
<SignupForm />
|
||||||
<div class="px-1 text-sm text-n-slate-12">
|
<div class="px-1 text-sm text-n-slate-12">
|
||||||
<span>{{ $t('REGISTER.HAVE_AN_ACCOUNT') }} </span>
|
<span>{{ $t('REGISTER.HAVE_AN_ACCOUNT') }}</span>
|
||||||
<router-link class="text-link text-n-brand" to="/app/login">
|
<router-link class="text-link text-n-brand mx-1" to="/app/login">
|
||||||
{{ replaceInstallationName($t('LOGIN.TITLE')) }}
|
{{ replaceInstallationName($t('LOGIN.TITLE')) }}
|
||||||
</router-link>
|
</router-link>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,188 +1,196 @@
|
|||||||
<script>
|
<script setup>
|
||||||
|
import { ref, reactive, computed } from 'vue';
|
||||||
import { useVuelidate } from '@vuelidate/core';
|
import { useVuelidate } from '@vuelidate/core';
|
||||||
import { required, minLength, email, sameAs } from '@vuelidate/validators';
|
import { required, minLength, email } from '@vuelidate/validators';
|
||||||
import { mapGetters } from 'vuex';
|
import { useStore } from 'vuex';
|
||||||
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useAlert } from 'dashboard/composables';
|
import { useAlert } from 'dashboard/composables';
|
||||||
import { DEFAULT_REDIRECT_URL } from 'dashboard/constants/globals';
|
import { DEFAULT_REDIRECT_URL } from 'dashboard/constants/globals';
|
||||||
import VueHcaptcha from '@hcaptcha/vue3-hcaptcha';
|
import VueHcaptcha from '@hcaptcha/vue3-hcaptcha';
|
||||||
import SimpleDivider from '../../../../../components/Divider/SimpleDivider.vue';
|
import SimpleDivider from '../../../../../components/Divider/SimpleDivider.vue';
|
||||||
import FormInput from '../../../../../components/Form/Input.vue';
|
import Input from 'dashboard/components-next/input/Input.vue';
|
||||||
import NextButton from 'dashboard/components-next/button/Button.vue';
|
import NextButton from 'dashboard/components-next/button/Button.vue';
|
||||||
import Icon from 'dashboard/components-next/icon/Icon.vue';
|
|
||||||
import { isValidPassword } from 'shared/helpers/Validators';
|
import { isValidPassword } from 'shared/helpers/Validators';
|
||||||
import GoogleOAuthButton from '../../../../../components/GoogleOauth/Button.vue';
|
import GoogleOAuthButton from '../../../../../components/GoogleOauth/Button.vue';
|
||||||
import { register } from '../../../../../api/auth';
|
import { register } from '../../../../../api/auth';
|
||||||
import * as CompanyEmailValidator from 'company-email-validator';
|
import * as CompanyEmailValidator from 'company-email-validator';
|
||||||
|
import PasswordRequirements from './PasswordRequirements.vue';
|
||||||
|
|
||||||
const MIN_PASSWORD_LENGTH = 6;
|
const MIN_PASSWORD_LENGTH = 6;
|
||||||
const SPECIAL_CHAR_REGEX = /[!@#$%^&*()_+\-=[\]{}|'"/\\.,`<>:;?~]/;
|
|
||||||
|
|
||||||
export default {
|
const store = useStore();
|
||||||
components: {
|
const { t } = useI18n();
|
||||||
FormInput,
|
|
||||||
GoogleOAuthButton,
|
const hCaptcha = ref(null);
|
||||||
NextButton,
|
const credentials = reactive({
|
||||||
SimpleDivider,
|
accountName: '',
|
||||||
Icon,
|
fullName: '',
|
||||||
VueHcaptcha,
|
email: '',
|
||||||
},
|
password: '',
|
||||||
setup() {
|
hCaptchaClientResponse: '',
|
||||||
return { v$: useVuelidate() };
|
});
|
||||||
},
|
const didCaptchaReset = ref(false);
|
||||||
data() {
|
const isSignupInProgress = ref(false);
|
||||||
return {
|
const isPasswordFocused = ref(false);
|
||||||
credentials: {
|
|
||||||
accountName: '',
|
const rules = computed(() => ({
|
||||||
fullName: '',
|
credentials: {
|
||||||
email: '',
|
accountName: {
|
||||||
password: '',
|
required,
|
||||||
confirmPassword: '',
|
minLength: minLength(2),
|
||||||
hCaptchaClientResponse: '',
|
},
|
||||||
|
fullName: {
|
||||||
|
required,
|
||||||
|
minLength: minLength(2),
|
||||||
|
},
|
||||||
|
email: {
|
||||||
|
required,
|
||||||
|
email,
|
||||||
|
businessEmailValidator(value) {
|
||||||
|
return CompanyEmailValidator.isCompanyEmail(value);
|
||||||
},
|
},
|
||||||
didCaptchaReset: false,
|
|
||||||
isSignupInProgress: false,
|
|
||||||
error: '',
|
|
||||||
};
|
|
||||||
},
|
|
||||||
validations() {
|
|
||||||
return {
|
|
||||||
credentials: {
|
|
||||||
accountName: {
|
|
||||||
required,
|
|
||||||
minLength: minLength(2),
|
|
||||||
},
|
|
||||||
fullName: {
|
|
||||||
required,
|
|
||||||
minLength: minLength(2),
|
|
||||||
},
|
|
||||||
email: {
|
|
||||||
required,
|
|
||||||
email,
|
|
||||||
businessEmailValidator(value) {
|
|
||||||
return CompanyEmailValidator.isCompanyEmail(value);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
password: {
|
|
||||||
required,
|
|
||||||
isValidPassword,
|
|
||||||
minLength: minLength(MIN_PASSWORD_LENGTH),
|
|
||||||
},
|
|
||||||
confirmPassword: {
|
|
||||||
required,
|
|
||||||
minLength: minLength(MIN_PASSWORD_LENGTH),
|
|
||||||
sameAsPassword: sameAs(this.credentials.password),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
...mapGetters({ globalConfig: 'globalConfig/get' }),
|
|
||||||
termsLink() {
|
|
||||||
return this.$t('REGISTER.TERMS_ACCEPT')
|
|
||||||
.replace('https://www.chatwoot.com/terms', this.globalConfig.termsURL)
|
|
||||||
.replace(
|
|
||||||
'https://www.chatwoot.com/privacy-policy',
|
|
||||||
this.globalConfig.privacyURL
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
hasAValidCaptcha() {
|
password: {
|
||||||
if (this.globalConfig.hCaptchaSiteKey) {
|
required,
|
||||||
return !!this.credentials.hCaptchaClientResponse;
|
isValidPassword,
|
||||||
}
|
minLength: minLength(MIN_PASSWORD_LENGTH),
|
||||||
return true;
|
|
||||||
},
|
|
||||||
confirmPasswordErrorText() {
|
|
||||||
const { confirmPassword } = this.v$.credentials;
|
|
||||||
if (!confirmPassword.$error) return '';
|
|
||||||
if (confirmPassword.sameAsPassword.$invalid) {
|
|
||||||
return this.$t('REGISTER.CONFIRM_PASSWORD.ERROR');
|
|
||||||
}
|
|
||||||
return '';
|
|
||||||
},
|
|
||||||
showGoogleOAuth() {
|
|
||||||
return Boolean(window.chatwootConfig.googleOAuthClientId);
|
|
||||||
},
|
|
||||||
isFormValid() {
|
|
||||||
return !this.v$.$invalid && this.hasAValidCaptcha;
|
|
||||||
},
|
|
||||||
passwordRequirements() {
|
|
||||||
const password = this.credentials.password || '';
|
|
||||||
return {
|
|
||||||
length: password.length >= MIN_PASSWORD_LENGTH,
|
|
||||||
uppercase: /[A-Z]/.test(password),
|
|
||||||
lowercase: /[a-z]/.test(password),
|
|
||||||
number: /[0-9]/.test(password),
|
|
||||||
special: SPECIAL_CHAR_REGEX.test(password),
|
|
||||||
};
|
|
||||||
},
|
|
||||||
passwordRequirementItems() {
|
|
||||||
const reqs = this.passwordRequirements;
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
id: 'length',
|
|
||||||
met: reqs.length,
|
|
||||||
label: this.$t('REGISTER.PASSWORD.REQUIREMENTS_LENGTH', {
|
|
||||||
min: MIN_PASSWORD_LENGTH,
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'uppercase',
|
|
||||||
met: reqs.uppercase,
|
|
||||||
label: this.$t('REGISTER.PASSWORD.REQUIREMENTS_UPPERCASE'),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'lowercase',
|
|
||||||
met: reqs.lowercase,
|
|
||||||
label: this.$t('REGISTER.PASSWORD.REQUIREMENTS_LOWERCASE'),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'number',
|
|
||||||
met: reqs.number,
|
|
||||||
label: this.$t('REGISTER.PASSWORD.REQUIREMENTS_NUMBER'),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'special',
|
|
||||||
met: reqs.special,
|
|
||||||
label: this.$t('REGISTER.PASSWORD.REQUIREMENTS_SPECIAL'),
|
|
||||||
},
|
|
||||||
];
|
|
||||||
},
|
|
||||||
passwordRequirementsMet() {
|
|
||||||
return Object.values(this.passwordRequirements).every(Boolean);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
async submit() {
|
|
||||||
this.v$.$touch();
|
|
||||||
if (this.v$.$invalid) {
|
|
||||||
this.resetCaptcha();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.isSignupInProgress = true;
|
|
||||||
try {
|
|
||||||
await register(this.credentials);
|
|
||||||
window.location = DEFAULT_REDIRECT_URL;
|
|
||||||
} catch (error) {
|
|
||||||
let errorMessage =
|
|
||||||
error?.message || this.$t('REGISTER.API.ERROR_MESSAGE');
|
|
||||||
this.resetCaptcha();
|
|
||||||
useAlert(errorMessage);
|
|
||||||
} finally {
|
|
||||||
this.isSignupInProgress = false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onRecaptchaVerified(token) {
|
|
||||||
this.credentials.hCaptchaClientResponse = token;
|
|
||||||
this.didCaptchaReset = false;
|
|
||||||
this.v$.$touch();
|
|
||||||
},
|
|
||||||
resetCaptcha() {
|
|
||||||
if (!this.globalConfig.hCaptchaSiteKey) return;
|
|
||||||
this.$refs.hCaptcha.reset();
|
|
||||||
this.credentials.hCaptchaClientResponse = '';
|
|
||||||
this.didCaptchaReset = true;
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
const v$ = useVuelidate(rules, { credentials });
|
||||||
|
|
||||||
|
const blurredFields = reactive({
|
||||||
|
fullName: false,
|
||||||
|
accountName: false,
|
||||||
|
email: false,
|
||||||
|
password: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
const shouldShowError = fieldName => {
|
||||||
|
// only when field has content and was blurred
|
||||||
|
const field = v$.value.credentials[fieldName];
|
||||||
|
const hasValue = credentials[fieldName] && credentials[fieldName].length > 0;
|
||||||
|
return hasValue && blurredFields[fieldName] && field.$error;
|
||||||
|
};
|
||||||
|
|
||||||
|
const shouldShowPasswordRequirementError = computed(() => {
|
||||||
|
const hasValue =
|
||||||
|
Boolean(credentials.password) && credentials.password.length > 0;
|
||||||
|
return hasValue && v$.value.credentials.password.$error;
|
||||||
|
});
|
||||||
|
|
||||||
|
const globalConfig = computed(() => store.getters['globalConfig/get']);
|
||||||
|
|
||||||
|
const termsLink = computed(() => {
|
||||||
|
return t('REGISTER.TERMS_ACCEPT')
|
||||||
|
.replace('https://www.chatwoot.com/terms', globalConfig.value.termsURL)
|
||||||
|
.replace(
|
||||||
|
'https://www.chatwoot.com/privacy-policy',
|
||||||
|
globalConfig.value.privacyURL
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
const hasAValidCaptcha = computed(() => {
|
||||||
|
if (globalConfig.value.hCaptchaSiteKey) {
|
||||||
|
return !!credentials.hCaptchaClientResponse;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
const showGoogleOAuth = computed(() => {
|
||||||
|
return Boolean(window.chatwootConfig.googleOAuthClientId);
|
||||||
|
});
|
||||||
|
|
||||||
|
const isFormValid = computed(() => {
|
||||||
|
return !v$.value.$invalid;
|
||||||
|
});
|
||||||
|
const resetCaptcha = () => {
|
||||||
|
if (!globalConfig.value.hCaptchaSiteKey) return;
|
||||||
|
hCaptcha.value.reset();
|
||||||
|
credentials.hCaptchaClientResponse = '';
|
||||||
|
didCaptchaReset.value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
const submit = async () => {
|
||||||
|
v$.value.$touch();
|
||||||
|
if (v$.value.$invalid) {
|
||||||
|
resetCaptcha();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// For invisible captcha, there is no user input. We have to execute it if when
|
||||||
|
// the user submits the form. If 99.9% Passive mode is enabled, the users won't
|
||||||
|
// be prompted to solve the captcha
|
||||||
|
if (
|
||||||
|
globalConfig.value.hCaptchaSiteKey &&
|
||||||
|
!credentials.hCaptchaClientResponse
|
||||||
|
) {
|
||||||
|
hCaptcha.value.execute();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
isSignupInProgress.value = true;
|
||||||
|
try {
|
||||||
|
await register(credentials);
|
||||||
|
window.location = DEFAULT_REDIRECT_URL;
|
||||||
|
} catch (error) {
|
||||||
|
let errorMessage = error?.message || t('REGISTER.API.ERROR_MESSAGE');
|
||||||
|
resetCaptcha();
|
||||||
|
useAlert(errorMessage);
|
||||||
|
} finally {
|
||||||
|
isSignupInProgress.value = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const onRecaptchaVerified = token => {
|
||||||
|
credentials.hCaptchaClientResponse = token;
|
||||||
|
didCaptchaReset.value = false;
|
||||||
|
v$.value.$touch();
|
||||||
|
// Auto-submit after captcha verification for invisible mode
|
||||||
|
submit();
|
||||||
|
};
|
||||||
|
|
||||||
|
const onCaptchaExpired = () => {
|
||||||
|
credentials.hCaptchaClientResponse = '';
|
||||||
|
didCaptchaReset.value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
const onCaptchaError = () => {
|
||||||
|
credentials.hCaptchaClientResponse = '';
|
||||||
|
didCaptchaReset.value = true;
|
||||||
|
useAlert(t('SET_NEW_PASSWORD.CAPTCHA.ERROR'));
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleFieldFocus = fieldName => {
|
||||||
|
// Clear blur state when user focuses field again
|
||||||
|
blurredFields[fieldName] = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleFieldBlur = fieldName => {
|
||||||
|
// Mark field as blurred and touch for validation
|
||||||
|
blurredFields[fieldName] = true;
|
||||||
|
v$.value.credentials[fieldName].$touch();
|
||||||
|
};
|
||||||
|
|
||||||
|
const handlePasswordInput = () => {
|
||||||
|
// Touch password field for real-time validation in requirements panel
|
||||||
|
if (credentials.password && credentials.password.length > 0) {
|
||||||
|
v$.value.credentials.password.$touch();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handlePasswordFocus = () => {
|
||||||
|
handleFieldFocus('password');
|
||||||
|
isPasswordFocused.value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
const handlePasswordBlur = () => {
|
||||||
|
handleFieldBlur('password');
|
||||||
|
// Delay hiding requirements to allow submit button click to register
|
||||||
|
setTimeout(() => {
|
||||||
|
isPasswordFocused.value = false;
|
||||||
|
}, 150);
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -190,90 +198,78 @@ export default {
|
|||||||
<div class="flex-1 px-1 overflow-auto">
|
<div class="flex-1 px-1 overflow-auto">
|
||||||
<form class="space-y-3" @submit.prevent="submit">
|
<form class="space-y-3" @submit.prevent="submit">
|
||||||
<div class="grid grid-cols-2 gap-2">
|
<div class="grid grid-cols-2 gap-2">
|
||||||
<FormInput
|
<Input
|
||||||
v-model="credentials.fullName"
|
v-model="credentials.fullName"
|
||||||
name="full_name"
|
name="full_name"
|
||||||
|
autocomplete="name"
|
||||||
class="flex-1"
|
class="flex-1"
|
||||||
:class="{ error: v$.credentials.fullName.$error }"
|
|
||||||
:label="$t('REGISTER.FULL_NAME.LABEL')"
|
:label="$t('REGISTER.FULL_NAME.LABEL')"
|
||||||
:placeholder="$t('REGISTER.FULL_NAME.PLACEHOLDER')"
|
:placeholder="$t('REGISTER.FULL_NAME.PLACEHOLDER')"
|
||||||
:has-error="v$.credentials.fullName.$error"
|
:message-type="shouldShowError('fullName') ? 'error' : ''"
|
||||||
:error-message="$t('REGISTER.FULL_NAME.ERROR')"
|
:message="
|
||||||
@blur="v$.credentials.fullName.$touch"
|
shouldShowError('fullName') ? $t('REGISTER.FULL_NAME.ERROR') : ''
|
||||||
|
"
|
||||||
|
@focus="handleFieldFocus('fullName')"
|
||||||
|
@blur="handleFieldBlur('fullName')"
|
||||||
/>
|
/>
|
||||||
<FormInput
|
<Input
|
||||||
v-model="credentials.accountName"
|
v-model="credentials.accountName"
|
||||||
name="account_name"
|
name="account_name"
|
||||||
|
autocomplete="organization"
|
||||||
class="flex-1"
|
class="flex-1"
|
||||||
:class="{ error: v$.credentials.accountName.$error }"
|
|
||||||
:label="$t('REGISTER.COMPANY_NAME.LABEL')"
|
:label="$t('REGISTER.COMPANY_NAME.LABEL')"
|
||||||
:placeholder="$t('REGISTER.COMPANY_NAME.PLACEHOLDER')"
|
:placeholder="$t('REGISTER.COMPANY_NAME.PLACEHOLDER')"
|
||||||
:has-error="v$.credentials.accountName.$error"
|
:message-type="shouldShowError('accountName') ? 'error' : ''"
|
||||||
:error-message="$t('REGISTER.COMPANY_NAME.ERROR')"
|
:message="
|
||||||
@blur="v$.credentials.accountName.$touch"
|
shouldShowError('accountName')
|
||||||
|
? $t('REGISTER.COMPANY_NAME.ERROR')
|
||||||
|
: ''
|
||||||
|
"
|
||||||
|
@focus="handleFieldFocus('accountName')"
|
||||||
|
@blur="handleFieldBlur('accountName')"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<FormInput
|
<Input
|
||||||
v-model="credentials.email"
|
v-model="credentials.email"
|
||||||
type="email"
|
type="email"
|
||||||
name="email_address"
|
name="email_address"
|
||||||
:class="{ error: v$.credentials.email.$error }"
|
autocomplete="email"
|
||||||
:label="$t('REGISTER.EMAIL.LABEL')"
|
:label="$t('REGISTER.EMAIL.LABEL')"
|
||||||
:placeholder="$t('REGISTER.EMAIL.PLACEHOLDER')"
|
:placeholder="$t('REGISTER.EMAIL.PLACEHOLDER')"
|
||||||
:has-error="v$.credentials.email.$error"
|
:message-type="shouldShowError('email') ? 'error' : ''"
|
||||||
:error-message="$t('REGISTER.EMAIL.ERROR')"
|
:message="shouldShowError('email') ? $t('REGISTER.EMAIL.ERROR') : ''"
|
||||||
@blur="v$.credentials.email.$touch"
|
@focus="handleFieldFocus('email')"
|
||||||
|
@blur="handleFieldBlur('email')"
|
||||||
/>
|
/>
|
||||||
<FormInput
|
<Input
|
||||||
v-model="credentials.password"
|
v-model="credentials.password"
|
||||||
type="password"
|
type="password"
|
||||||
name="password"
|
name="password"
|
||||||
:class="{ error: v$.credentials.password.$error }"
|
autocomplete="new-password"
|
||||||
:label="$t('LOGIN.PASSWORD.LABEL')"
|
:label="$t('LOGIN.PASSWORD.LABEL')"
|
||||||
:placeholder="$t('SET_NEW_PASSWORD.PASSWORD.PLACEHOLDER')"
|
:placeholder="$t('SET_NEW_PASSWORD.PASSWORD.PLACEHOLDER')"
|
||||||
:has-error="v$.credentials.password.$error"
|
:message-type="shouldShowError('password') ? 'error' : ''"
|
||||||
aria-describedby="password-requirements"
|
aria-describedby="password-requirements"
|
||||||
@blur="v$.credentials.password.$touch"
|
@input="handlePasswordInput"
|
||||||
|
@focus="handlePasswordFocus"
|
||||||
|
@blur="handlePasswordBlur"
|
||||||
/>
|
/>
|
||||||
<div
|
<PasswordRequirements
|
||||||
id="password-requirements"
|
:password="credentials.password"
|
||||||
class="text-xs rounded-md px-4 py-3 outline outline-1 outline-n-weak bg-n-alpha-black2"
|
:open="isPasswordFocused"
|
||||||
>
|
:show-error="shouldShowPasswordRequirementError"
|
||||||
<ul role="list" class="grid grid-cols-2 gap-1">
|
:min-length="MIN_PASSWORD_LENGTH"
|
||||||
<li
|
|
||||||
v-for="item in passwordRequirementItems"
|
|
||||||
:key="item.id"
|
|
||||||
class="inline-flex gap-1 items-start"
|
|
||||||
>
|
|
||||||
<Icon
|
|
||||||
class="flex-none flex-shrink-0 w-3 mt-0.5"
|
|
||||||
:icon="item.met ? 'i-lucide-circle-check-big' : 'i-lucide-circle'"
|
|
||||||
:class="item.met ? 'text-n-teal-10' : 'text-n-slate-10'"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<span :class="item.met ? 'text-n-slate-11' : 'text-n-slate-10'">
|
|
||||||
{{ item.label }}
|
|
||||||
</span>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<FormInput
|
|
||||||
v-model="credentials.confirmPassword"
|
|
||||||
type="password"
|
|
||||||
name="confirm_password"
|
|
||||||
:class="{ error: v$.credentials.confirmPassword.$error }"
|
|
||||||
:label="$t('REGISTER.CONFIRM_PASSWORD.LABEL')"
|
|
||||||
:placeholder="$t('REGISTER.CONFIRM_PASSWORD.PLACEHOLDER')"
|
|
||||||
:has-error="v$.credentials.confirmPassword.$error"
|
|
||||||
:error-message="confirmPasswordErrorText"
|
|
||||||
@blur="v$.credentials.confirmPassword.$touch"
|
|
||||||
/>
|
/>
|
||||||
<div v-if="globalConfig.hCaptchaSiteKey" class="mb-3">
|
<div v-if="globalConfig.hCaptchaSiteKey" class="mb-3">
|
||||||
<VueHcaptcha
|
<VueHcaptcha
|
||||||
ref="hCaptcha"
|
ref="hCaptcha"
|
||||||
:class="{ error: !hasAValidCaptcha && didCaptchaReset }"
|
:class="{ error: !hasAValidCaptcha && didCaptchaReset }"
|
||||||
:sitekey="globalConfig.hCaptchaSiteKey"
|
:sitekey="globalConfig.hCaptchaSiteKey"
|
||||||
|
size="invisible"
|
||||||
@verify="onRecaptchaVerified"
|
@verify="onRecaptchaVerified"
|
||||||
|
@expired="onCaptchaExpired"
|
||||||
|
@challenge-expired="onCaptchaExpired"
|
||||||
|
@error="onCaptchaError"
|
||||||
/>
|
/>
|
||||||
<span
|
<span
|
||||||
v-if="!hasAValidCaptcha && didCaptchaReset"
|
v-if="!hasAValidCaptcha && didCaptchaReset"
|
||||||
|
|||||||
@@ -0,0 +1,122 @@
|
|||||||
|
<script setup>
|
||||||
|
import { computed } from 'vue';
|
||||||
|
import { useI18n } from 'vue-i18n';
|
||||||
|
import Icon from 'dashboard/components-next/icon/Icon.vue';
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
password: { type: String, default: '' },
|
||||||
|
open: { type: Boolean, default: false },
|
||||||
|
showError: { type: Boolean, default: false },
|
||||||
|
minLength: { type: Number, default: 6 },
|
||||||
|
});
|
||||||
|
|
||||||
|
const SPECIAL_CHAR_REGEX = /[!@#$%^&*()_+\-=[\]{}|'"/\\.,`<>:;?~]/;
|
||||||
|
|
||||||
|
const { t } = useI18n();
|
||||||
|
|
||||||
|
const passwordRequirements = computed(() => {
|
||||||
|
const pwd = props.password || '';
|
||||||
|
return {
|
||||||
|
length: pwd.length >= props.minLength,
|
||||||
|
uppercase: /[A-Z]/.test(pwd),
|
||||||
|
lowercase: /[a-z]/.test(pwd),
|
||||||
|
number: /[0-9]/.test(pwd),
|
||||||
|
special: SPECIAL_CHAR_REGEX.test(pwd),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
const passwordRequirementItems = computed(() => {
|
||||||
|
const reqs = passwordRequirements.value;
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
id: 'length',
|
||||||
|
met: reqs.length,
|
||||||
|
label: t('REGISTER.PASSWORD.REQUIREMENTS_LENGTH', {
|
||||||
|
min: props.minLength,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'uppercase',
|
||||||
|
met: reqs.uppercase,
|
||||||
|
label: t('REGISTER.PASSWORD.REQUIREMENTS_UPPERCASE'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'lowercase',
|
||||||
|
met: reqs.lowercase,
|
||||||
|
label: t('REGISTER.PASSWORD.REQUIREMENTS_LOWERCASE'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'number',
|
||||||
|
met: reqs.number,
|
||||||
|
label: t('REGISTER.PASSWORD.REQUIREMENTS_NUMBER'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'special',
|
||||||
|
met: reqs.special,
|
||||||
|
label: t('REGISTER.PASSWORD.REQUIREMENTS_SPECIAL'),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div
|
||||||
|
class="grid transition-all duration-300 ease-in-out"
|
||||||
|
:class="[open ? 'grid-rows-[1fr] !mt-1' : 'grid-rows-[0fr] !mt-0']"
|
||||||
|
>
|
||||||
|
<div class="overflow-hidden">
|
||||||
|
<Transition
|
||||||
|
enter-active-class="transition-all duration-300 ease-in-out"
|
||||||
|
leave-active-class="transition-all duration-300 ease-in-out"
|
||||||
|
enter-from-class="opacity-0 -translate-y-2"
|
||||||
|
enter-to-class="opacity-100 translate-y-0"
|
||||||
|
leave-from-class="opacity-100 translate-y-0"
|
||||||
|
leave-to-class="opacity-0 -translate-y-2"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
v-if="open"
|
||||||
|
id="password-requirements"
|
||||||
|
class="text-xs rounded-lg px-3 py-2.5 outline outline-1 -outline-offset-1 outline-n-weak bg-n-alpha-black2"
|
||||||
|
>
|
||||||
|
<ul role="list" class="grid grid-cols-2 gap-1">
|
||||||
|
<li
|
||||||
|
v-for="item in passwordRequirementItems"
|
||||||
|
:key="item.id"
|
||||||
|
class="inline-flex gap-1 items-start"
|
||||||
|
>
|
||||||
|
<Icon
|
||||||
|
class="flex-none flex-shrink-0 w-3 mt-0.5"
|
||||||
|
:icon="
|
||||||
|
item.met
|
||||||
|
? 'i-lucide-circle-check'
|
||||||
|
: showError
|
||||||
|
? 'i-lucide-circle-x'
|
||||||
|
: 'i-lucide-circle-dot'
|
||||||
|
"
|
||||||
|
:class="
|
||||||
|
item.met
|
||||||
|
? 'text-n-teal-9'
|
||||||
|
: showError
|
||||||
|
? 'text-n-ruby-9'
|
||||||
|
: 'text-n-slate-10'
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<span
|
||||||
|
:class="
|
||||||
|
item.met
|
||||||
|
? 'text-n-teal-11'
|
||||||
|
: showError
|
||||||
|
? 'text-n-ruby-11'
|
||||||
|
: 'text-n-slate-11'
|
||||||
|
"
|
||||||
|
>
|
||||||
|
{{ item.label }}
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</Transition>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -1,34 +1,32 @@
|
|||||||
<script>
|
<script setup>
|
||||||
|
import { ref, onBeforeMount } from 'vue';
|
||||||
import TestimonialCard from './TestimonialCard.vue';
|
import TestimonialCard from './TestimonialCard.vue';
|
||||||
import { getTestimonialContent } from '../../../../../api/testimonials';
|
import { getTestimonialContent } from '../../../../../api/testimonials';
|
||||||
export default {
|
|
||||||
components: { TestimonialCard },
|
const emit = defineEmits(['resizeContainers']);
|
||||||
emits: ['resizeContainers'],
|
|
||||||
data() {
|
const testimonials = ref([]);
|
||||||
return { testimonials: [] };
|
|
||||||
},
|
const fetchTestimonials = async () => {
|
||||||
beforeMount() {
|
try {
|
||||||
this.fetchTestimonials();
|
const { data } = await getTestimonialContent();
|
||||||
},
|
testimonials.value = data;
|
||||||
methods: {
|
} catch (error) {
|
||||||
async fetchTestimonials() {
|
// Ignoring the error as the UI wouldn't break
|
||||||
try {
|
} finally {
|
||||||
const { data } = await getTestimonialContent();
|
emit('resizeContainers', !!testimonials.value.length);
|
||||||
this.testimonials = data;
|
}
|
||||||
} catch (error) {
|
|
||||||
// Ignoring the error as the UI wouldn't break
|
|
||||||
} finally {
|
|
||||||
this.$emit('resizeContainers', !!this.testimonials.length);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
onBeforeMount(() => {
|
||||||
|
fetchTestimonials();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
v-show="testimonials.length"
|
v-show="testimonials.length"
|
||||||
class="relative flex-1 min-h-screen hidden overflow-hidden bg-n-blue-8 dark:bg-n-blue-5 xl:flex"
|
class="relative self-stretch hidden overflow-hidden bg-n-blue-8 dark:bg-n-blue-5 xl:flex"
|
||||||
>
|
>
|
||||||
<img
|
<img
|
||||||
src="assets/images/auth/top-left.svg"
|
src="assets/images/auth/top-left.svg"
|
||||||
@@ -42,9 +40,7 @@ export default {
|
|||||||
src="assets/images/auth/auth--bg.svg"
|
src="assets/images/auth/auth--bg.svg"
|
||||||
class="h-[96%] left-[6%] top-[8%] w-[96%] absolute"
|
class="h-[96%] left-[6%] top-[8%] w-[96%] absolute"
|
||||||
/>
|
/>
|
||||||
<div
|
<div class="z-50 flex flex-col items-center justify-center w-full h-full">
|
||||||
class="z-50 flex flex-col items-center justify-center w-full h-full min-h-screen"
|
|
||||||
>
|
|
||||||
<div class="flex items-start justify-center p-6">
|
<div class="flex items-start justify-center p-6">
|
||||||
<TestimonialCard
|
<TestimonialCard
|
||||||
v-for="(testimonial, index) in testimonials"
|
v-for="(testimonial, index) in testimonials"
|
||||||
|
|||||||
@@ -1,24 +1,22 @@
|
|||||||
<script>
|
<script setup>
|
||||||
export default {
|
defineProps({
|
||||||
props: {
|
reviewContent: {
|
||||||
reviewContent: {
|
type: String,
|
||||||
type: String,
|
default: '',
|
||||||
default: '',
|
|
||||||
},
|
|
||||||
authorImage: {
|
|
||||||
type: String,
|
|
||||||
default: '',
|
|
||||||
},
|
|
||||||
authorName: {
|
|
||||||
type: String,
|
|
||||||
default: '',
|
|
||||||
},
|
|
||||||
authorDesignation: {
|
|
||||||
type: String,
|
|
||||||
default: '',
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
};
|
authorImage: {
|
||||||
|
type: String,
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
authorName: {
|
||||||
|
type: String,
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
authorDesignation: {
|
||||||
|
type: String,
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
@@ -1,24 +1,32 @@
|
|||||||
<script>
|
<script setup>
|
||||||
// utils and composables
|
import { ref, reactive, computed, onMounted } from 'vue';
|
||||||
import { login } from '../../api/auth';
|
import { useVuelidate } from '@vuelidate/core';
|
||||||
import { mapGetters } from 'vuex';
|
import { required, email as emailValidator } from '@vuelidate/validators';
|
||||||
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
|
import { useI18n } from 'vue-i18n';
|
||||||
import { parseBoolean } from '@chatwoot/utils';
|
import { parseBoolean } from '@chatwoot/utils';
|
||||||
import { useAlert } from 'dashboard/composables';
|
import { useAlert } from 'dashboard/composables';
|
||||||
import { required, email } from '@vuelidate/validators';
|
import { useMapGetter } from 'dashboard/composables/store';
|
||||||
import { useVuelidate } from '@vuelidate/core';
|
import { useBranding } from 'shared/composables/useBranding';
|
||||||
import { SESSION_STORAGE_KEYS } from 'dashboard/constants/sessionStorage';
|
import { SESSION_STORAGE_KEYS } from 'dashboard/constants/sessionStorage';
|
||||||
import SessionStorage from 'shared/helpers/sessionStorage';
|
import SessionStorage from 'shared/helpers/sessionStorage';
|
||||||
import { useBranding } from 'shared/composables/useBranding';
|
import { login } from '../../api/auth';
|
||||||
|
|
||||||
// components
|
|
||||||
import SimpleDivider from '../../components/Divider/SimpleDivider.vue';
|
import SimpleDivider from '../../components/Divider/SimpleDivider.vue';
|
||||||
import FormInput from '../../components/Form/Input.vue';
|
import Input from 'dashboard/components-next/input/Input.vue';
|
||||||
import GoogleOAuthButton from '../../components/GoogleOauth/Button.vue';
|
import GoogleOAuthButton from '../../components/GoogleOauth/Button.vue';
|
||||||
import Spinner from 'shared/components/Spinner.vue';
|
import Spinner from 'shared/components/Spinner.vue';
|
||||||
import Icon from 'dashboard/components-next/icon/Icon.vue';
|
import Icon from 'dashboard/components-next/icon/Icon.vue';
|
||||||
import NextButton from 'dashboard/components-next/button/Button.vue';
|
import NextButton from 'dashboard/components-next/button/Button.vue';
|
||||||
import MfaVerification from 'dashboard/components/auth/MfaVerification.vue';
|
import MfaVerification from 'dashboard/components/auth/MfaVerification.vue';
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
ssoAuthToken: { type: String, default: '' },
|
||||||
|
ssoAccountId: { type: String, default: '' },
|
||||||
|
ssoConversationId: { type: String, default: '' },
|
||||||
|
email: { type: String, default: '' },
|
||||||
|
authError: { type: String, default: '' },
|
||||||
|
});
|
||||||
|
|
||||||
const ERROR_MESSAGES = {
|
const ERROR_MESSAGES = {
|
||||||
'no-account-found': 'LOGIN.OAUTH.NO_ACCOUNT_FOUND',
|
'no-account-found': 'LOGIN.OAUTH.NO_ACCOUNT_FOUND',
|
||||||
'business-account-only': 'LOGIN.OAUTH.BUSINESS_ACCOUNTS_ONLY',
|
'business-account-only': 'LOGIN.OAUTH.BUSINESS_ACCOUNTS_ONLY',
|
||||||
@@ -28,189 +36,162 @@ const ERROR_MESSAGES = {
|
|||||||
|
|
||||||
const IMPERSONATION_URL_SEARCH_KEY = 'impersonation';
|
const IMPERSONATION_URL_SEARCH_KEY = 'impersonation';
|
||||||
|
|
||||||
export default {
|
const route = useRoute();
|
||||||
components: {
|
const router = useRouter();
|
||||||
FormInput,
|
const { t } = useI18n();
|
||||||
GoogleOAuthButton,
|
const { replaceInstallationName } = useBranding();
|
||||||
Spinner,
|
|
||||||
NextButton,
|
|
||||||
SimpleDivider,
|
|
||||||
MfaVerification,
|
|
||||||
Icon,
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
ssoAuthToken: { type: String, default: '' },
|
|
||||||
ssoAccountId: { type: String, default: '' },
|
|
||||||
ssoConversationId: { type: String, default: '' },
|
|
||||||
email: { type: String, default: '' },
|
|
||||||
authError: { type: String, default: '' },
|
|
||||||
},
|
|
||||||
setup() {
|
|
||||||
const { replaceInstallationName } = useBranding();
|
|
||||||
return {
|
|
||||||
replaceInstallationName,
|
|
||||||
v$: useVuelidate(),
|
|
||||||
};
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
// We need to initialize the component with any
|
|
||||||
// properties that will be used in it
|
|
||||||
credentials: {
|
|
||||||
email: '',
|
|
||||||
password: '',
|
|
||||||
},
|
|
||||||
loginApi: {
|
|
||||||
message: '',
|
|
||||||
showLoading: false,
|
|
||||||
hasErrored: false,
|
|
||||||
},
|
|
||||||
error: '',
|
|
||||||
mfaRequired: false,
|
|
||||||
mfaToken: null,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
validations() {
|
|
||||||
return {
|
|
||||||
credentials: {
|
|
||||||
password: {
|
|
||||||
required,
|
|
||||||
},
|
|
||||||
email: {
|
|
||||||
required,
|
|
||||||
email,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
...mapGetters({ globalConfig: 'globalConfig/get' }),
|
|
||||||
showGoogleOAuth() {
|
|
||||||
return Boolean(window.chatwootConfig.googleOAuthClientId);
|
|
||||||
},
|
|
||||||
showSignupLink() {
|
|
||||||
return parseBoolean(window.chatwootConfig.signupEnabled);
|
|
||||||
},
|
|
||||||
showSamlLogin() {
|
|
||||||
return this.globalConfig.isEnterprise;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
created() {
|
|
||||||
if (this.ssoAuthToken) {
|
|
||||||
this.submitLogin();
|
|
||||||
}
|
|
||||||
if (this.authError) {
|
|
||||||
const messageKey = ERROR_MESSAGES[this.authError] ?? 'LOGIN.API.UNAUTH';
|
|
||||||
// Use a method to get the translated text to avoid dynamic key warning
|
|
||||||
const translatedMessage = this.getTranslatedMessage(messageKey);
|
|
||||||
useAlert(translatedMessage);
|
|
||||||
// wait for idle state
|
|
||||||
this.requestIdleCallbackPolyfill(() => {
|
|
||||||
// Remove the error query param from the url
|
|
||||||
const { query } = this.$route;
|
|
||||||
this.$router.replace({ query: { ...query, error: undefined } });
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
getTranslatedMessage(key) {
|
|
||||||
// Avoid dynamic key warning by handling each case explicitly
|
|
||||||
switch (key) {
|
|
||||||
case 'LOGIN.OAUTH.NO_ACCOUNT_FOUND':
|
|
||||||
return this.$t('LOGIN.OAUTH.NO_ACCOUNT_FOUND');
|
|
||||||
case 'LOGIN.OAUTH.BUSINESS_ACCOUNTS_ONLY':
|
|
||||||
return this.$t('LOGIN.OAUTH.BUSINESS_ACCOUNTS_ONLY');
|
|
||||||
case 'LOGIN.API.UNAUTH':
|
|
||||||
default:
|
|
||||||
return this.$t('LOGIN.API.UNAUTH');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// TODO: Remove this when Safari gets wider support
|
|
||||||
// Ref: https://caniuse.com/requestidlecallback
|
|
||||||
//
|
|
||||||
requestIdleCallbackPolyfill(callback) {
|
|
||||||
if (window.requestIdleCallback) {
|
|
||||||
window.requestIdleCallback(callback);
|
|
||||||
} else {
|
|
||||||
// Fallback for safari
|
|
||||||
// Using a delay of 0 allows the callback to be executed asynchronously
|
|
||||||
// in the next available event loop iteration, similar to requestIdleCallback
|
|
||||||
setTimeout(callback, 0);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
showAlertMessage(message) {
|
|
||||||
// Reset loading, current selected agent
|
|
||||||
this.loginApi.showLoading = false;
|
|
||||||
this.loginApi.message = message;
|
|
||||||
useAlert(this.loginApi.message);
|
|
||||||
},
|
|
||||||
handleImpersonation() {
|
|
||||||
// Detects impersonation mode via URL and sets a session flag to prevent user settings changes during impersonation.
|
|
||||||
const urlParams = new URLSearchParams(window.location.search);
|
|
||||||
const impersonation = urlParams.get(IMPERSONATION_URL_SEARCH_KEY);
|
|
||||||
if (impersonation) {
|
|
||||||
SessionStorage.set(SESSION_STORAGE_KEYS.IMPERSONATION_USER, true);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
submitLogin() {
|
|
||||||
this.loginApi.hasErrored = false;
|
|
||||||
this.loginApi.showLoading = true;
|
|
||||||
|
|
||||||
const credentials = {
|
const globalConfig = useMapGetter('globalConfig/get');
|
||||||
email: this.email
|
|
||||||
? decodeURIComponent(this.email)
|
|
||||||
: this.credentials.email,
|
|
||||||
password: this.credentials.password,
|
|
||||||
sso_auth_token: this.ssoAuthToken,
|
|
||||||
ssoAccountId: this.ssoAccountId,
|
|
||||||
ssoConversationId: this.ssoConversationId,
|
|
||||||
};
|
|
||||||
|
|
||||||
login(credentials)
|
const credentials = reactive({
|
||||||
.then(result => {
|
email: '',
|
||||||
// Check if MFA is required
|
password: '',
|
||||||
if (result?.mfaRequired) {
|
});
|
||||||
this.loginApi.showLoading = false;
|
|
||||||
this.mfaRequired = true;
|
|
||||||
this.mfaToken = result.mfaToken;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.handleImpersonation();
|
const showLoading = ref(false);
|
||||||
this.showAlertMessage(this.$t('LOGIN.API.SUCCESS_MESSAGE'));
|
const hasErrored = ref(false);
|
||||||
})
|
const mfaRequired = ref(false);
|
||||||
.catch(response => {
|
const mfaToken = ref(null);
|
||||||
// Reset URL Params if the authentication is invalid
|
|
||||||
if (this.email) {
|
|
||||||
window.location = '/app/login';
|
|
||||||
}
|
|
||||||
this.loginApi.hasErrored = true;
|
|
||||||
this.showAlertMessage(
|
|
||||||
response?.message || this.$t('LOGIN.API.UNAUTH')
|
|
||||||
);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
submitFormLogin() {
|
|
||||||
if (this.v$.credentials.email.$invalid && !this.email) {
|
|
||||||
this.showAlertMessage(this.$t('LOGIN.EMAIL.ERROR'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.submitLogin();
|
const rules = computed(() => ({
|
||||||
|
credentials: {
|
||||||
|
password: {
|
||||||
|
required,
|
||||||
},
|
},
|
||||||
handleMfaVerified() {
|
email: {
|
||||||
// MFA verification successful, continue with login
|
required,
|
||||||
this.handleImpersonation();
|
email: emailValidator,
|
||||||
window.location = '/app';
|
|
||||||
},
|
|
||||||
handleMfaCancel() {
|
|
||||||
// User cancelled MFA, reset state
|
|
||||||
this.mfaRequired = false;
|
|
||||||
this.mfaToken = null;
|
|
||||||
this.credentials.password = '';
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
const v$ = useVuelidate(rules, { credentials });
|
||||||
|
|
||||||
|
const showGoogleOAuth = computed(() => {
|
||||||
|
return Boolean(window.chatwootConfig.googleOAuthClientId);
|
||||||
|
});
|
||||||
|
|
||||||
|
const showSignupLink = computed(() => {
|
||||||
|
return parseBoolean(window.chatwootConfig.signupEnabled);
|
||||||
|
});
|
||||||
|
|
||||||
|
const showSamlLogin = computed(() => {
|
||||||
|
return Boolean(globalConfig.value.isEnterprise);
|
||||||
|
});
|
||||||
|
|
||||||
|
const getTranslatedMessage = key => {
|
||||||
|
// Avoid dynamic key warning by handling each case explicitly
|
||||||
|
switch (key) {
|
||||||
|
case 'LOGIN.OAUTH.NO_ACCOUNT_FOUND':
|
||||||
|
return t('LOGIN.OAUTH.NO_ACCOUNT_FOUND');
|
||||||
|
case 'LOGIN.OAUTH.BUSINESS_ACCOUNTS_ONLY':
|
||||||
|
return t('LOGIN.OAUTH.BUSINESS_ACCOUNTS_ONLY');
|
||||||
|
case 'LOGIN.API.UNAUTH':
|
||||||
|
default:
|
||||||
|
return t('LOGIN.API.UNAUTH');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// TODO: Remove this when Safari gets wider support
|
||||||
|
// Ref: https://caniuse.com/requestidlecallback
|
||||||
|
const requestIdleCallbackPolyfill = callback => {
|
||||||
|
if (window.requestIdleCallback) {
|
||||||
|
window.requestIdleCallback(callback);
|
||||||
|
} else {
|
||||||
|
// Fallback for safari
|
||||||
|
// Using a delay of 0 allows the callback to be executed asynchronously
|
||||||
|
// in the next available event loop iteration, similar to requestIdleCallback
|
||||||
|
setTimeout(callback, 0);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const showAlertMessage = message => {
|
||||||
|
showLoading.value = false;
|
||||||
|
useAlert(message);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleImpersonation = () => {
|
||||||
|
// Detects impersonation mode via URL and sets a session flag to prevent user settings changes during impersonation.
|
||||||
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
|
const impersonation = urlParams.get(IMPERSONATION_URL_SEARCH_KEY);
|
||||||
|
if (impersonation) {
|
||||||
|
SessionStorage.set(SESSION_STORAGE_KEYS.IMPERSONATION_USER, true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const submitLogin = async () => {
|
||||||
|
hasErrored.value = false;
|
||||||
|
showLoading.value = true;
|
||||||
|
|
||||||
|
const loginCredentials = {
|
||||||
|
email: props.email ? decodeURIComponent(props.email) : credentials.email,
|
||||||
|
password: credentials.password,
|
||||||
|
sso_auth_token: props.ssoAuthToken,
|
||||||
|
ssoAccountId: props.ssoAccountId,
|
||||||
|
ssoConversationId: props.ssoConversationId,
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const result = await login(loginCredentials);
|
||||||
|
|
||||||
|
// Check if MFA is required
|
||||||
|
if (result?.mfaRequired) {
|
||||||
|
showLoading.value = false;
|
||||||
|
mfaRequired.value = true;
|
||||||
|
mfaToken.value = result.mfaToken;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
handleImpersonation();
|
||||||
|
showAlertMessage(t('LOGIN.API.SUCCESS_MESSAGE'));
|
||||||
|
} catch (response) {
|
||||||
|
// Reset URL Params if the authentication is invalid
|
||||||
|
if (props.email) {
|
||||||
|
window.location = '/app/login';
|
||||||
|
}
|
||||||
|
hasErrored.value = true;
|
||||||
|
showAlertMessage(response?.message || t('LOGIN.API.UNAUTH'));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const submitFormLogin = () => {
|
||||||
|
if (v$.value.credentials.email.$invalid && !props.email) {
|
||||||
|
showAlertMessage(t('LOGIN.EMAIL.ERROR'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
submitLogin();
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleMfaVerified = () => {
|
||||||
|
// MFA verification successful, continue with login
|
||||||
|
handleImpersonation();
|
||||||
|
window.location = '/app';
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleMfaCancel = () => {
|
||||||
|
// User cancelled MFA, reset state
|
||||||
|
mfaRequired.value = false;
|
||||||
|
mfaToken.value = null;
|
||||||
|
credentials.password = '';
|
||||||
|
};
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
if (props.ssoAuthToken) {
|
||||||
|
submitLogin();
|
||||||
|
}
|
||||||
|
if (props.authError) {
|
||||||
|
const messageKey = ERROR_MESSAGES[props.authError] ?? 'LOGIN.API.UNAUTH';
|
||||||
|
const translatedMessage = getTranslatedMessage(messageKey);
|
||||||
|
useAlert(translatedMessage);
|
||||||
|
// wait for idle state
|
||||||
|
requestIdleCallbackPolyfill(() => {
|
||||||
|
// Remove the error query param from the url
|
||||||
|
const { query } = route;
|
||||||
|
router.replace({ query: { ...query, error: undefined } });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -255,16 +236,16 @@ export default {
|
|||||||
class="bg-white shadow sm:mx-auto mt-11 sm:w-full sm:max-w-lg dark:bg-n-solid-2 p-11 sm:shadow-lg sm:rounded-lg"
|
class="bg-white shadow sm:mx-auto mt-11 sm:w-full sm:max-w-lg dark:bg-n-solid-2 p-11 sm:shadow-lg sm:rounded-lg"
|
||||||
:class="{
|
:class="{
|
||||||
'mb-8 mt-15': !showGoogleOAuth,
|
'mb-8 mt-15': !showGoogleOAuth,
|
||||||
'animate-wiggle': loginApi.hasErrored,
|
'animate-wiggle': hasErrored,
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<div v-if="!email">
|
<div v-if="!props.email">
|
||||||
<div class="flex flex-col gap-4">
|
<div class="flex flex-col gap-4">
|
||||||
<GoogleOAuthButton v-if="showGoogleOAuth" />
|
<GoogleOAuthButton v-if="showGoogleOAuth" />
|
||||||
<div v-if="showSamlLogin" class="text-center">
|
<div v-if="showSamlLogin" class="text-center">
|
||||||
<router-link
|
<router-link
|
||||||
to="/app/login/sso"
|
to="/app/login/sso"
|
||||||
class="inline-flex justify-center w-full px-4 py-3 items-center bg-n-background dark:bg-n-solid-3 rounded-md shadow-sm ring-1 ring-inset ring-n-container dark:ring-n-container focus:outline-offset-0 hover:bg-n-alpha-2 dark:hover:bg-n-alpha-2"
|
class="inline-flex justify-center w-full px-4 py-3 items-center bg-n-background dark:bg-n-solid-3 rounded-lg shadow-sm ring-1 ring-inset ring-n-container dark:ring-n-container focus:outline-offset-0 hover:bg-n-alpha-2 dark:hover:bg-n-alpha-2"
|
||||||
>
|
>
|
||||||
<Icon
|
<Icon
|
||||||
icon="i-lucide-lock-keyhole"
|
icon="i-lucide-lock-keyhole"
|
||||||
@@ -282,40 +263,47 @@ export default {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<form class="space-y-5" @submit.prevent="submitFormLogin">
|
<form class="space-y-5" @submit.prevent="submitFormLogin">
|
||||||
<FormInput
|
<Input
|
||||||
v-model="credentials.email"
|
v-model="credentials.email"
|
||||||
name="email_address"
|
name="email_address"
|
||||||
type="text"
|
type="text"
|
||||||
data-testid="email_input"
|
data-testid="email_input"
|
||||||
|
autocomplete="email"
|
||||||
:tabindex="1"
|
:tabindex="1"
|
||||||
required
|
required
|
||||||
:label="$t('LOGIN.EMAIL.LABEL')"
|
:label="$t('LOGIN.EMAIL.LABEL')"
|
||||||
:placeholder="$t('LOGIN.EMAIL.PLACEHOLDER')"
|
:placeholder="$t('LOGIN.EMAIL.PLACEHOLDER')"
|
||||||
:has-error="v$.credentials.email.$error"
|
:message-type="v$.credentials.email.$error ? 'error' : ''"
|
||||||
@input="v$.credentials.email.$touch"
|
@input="v$.credentials.email.$touch"
|
||||||
/>
|
/>
|
||||||
<FormInput
|
<Input
|
||||||
v-model="credentials.password"
|
v-model="credentials.password"
|
||||||
type="password"
|
type="password"
|
||||||
name="password"
|
name="password"
|
||||||
data-testid="password_input"
|
data-testid="password_input"
|
||||||
|
autocomplete="current-password"
|
||||||
required
|
required
|
||||||
:tabindex="2"
|
:tabindex="2"
|
||||||
:label="$t('LOGIN.PASSWORD.LABEL')"
|
:label="$t('LOGIN.PASSWORD.LABEL')"
|
||||||
:placeholder="$t('LOGIN.PASSWORD.PLACEHOLDER')"
|
:placeholder="$t('LOGIN.PASSWORD.PLACEHOLDER')"
|
||||||
:has-error="v$.credentials.password.$error"
|
:message-type="v$.credentials.password.$error ? 'error' : ''"
|
||||||
@input="v$.credentials.password.$touch"
|
@input="v$.credentials.password.$touch"
|
||||||
>
|
>
|
||||||
<p v-if="!globalConfig.disableUserProfileUpdate">
|
<template #prefix>
|
||||||
<router-link
|
<p
|
||||||
to="auth/reset/password"
|
v-if="!globalConfig.disableUserProfileUpdate"
|
||||||
class="text-sm text-link"
|
class="absolute ltr:right-0 rtl:left-0"
|
||||||
tabindex="4"
|
|
||||||
>
|
>
|
||||||
{{ $t('LOGIN.FORGOT_PASSWORD') }}
|
<router-link
|
||||||
</router-link>
|
to="auth/reset/password"
|
||||||
</p>
|
class="text-sm text-link"
|
||||||
</FormInput>
|
tabindex="4"
|
||||||
|
>
|
||||||
|
{{ $t('LOGIN.FORGOT_PASSWORD') }}
|
||||||
|
</router-link>
|
||||||
|
</p>
|
||||||
|
</template>
|
||||||
|
</Input>
|
||||||
<NextButton
|
<NextButton
|
||||||
lg
|
lg
|
||||||
type="submit"
|
type="submit"
|
||||||
@@ -323,8 +311,8 @@ export default {
|
|||||||
class="w-full"
|
class="w-full"
|
||||||
:tabindex="3"
|
:tabindex="3"
|
||||||
:label="$t('LOGIN.SUBMIT')"
|
:label="$t('LOGIN.SUBMIT')"
|
||||||
:disabled="loginApi.showLoading"
|
:disabled="showLoading"
|
||||||
:is-loading="loginApi.showLoading"
|
:is-loading="showLoading"
|
||||||
/>
|
/>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { useI18n } from 'vue-i18n';
|
|||||||
import { useAlert } from 'dashboard/composables';
|
import { useAlert } from 'dashboard/composables';
|
||||||
|
|
||||||
// components
|
// components
|
||||||
import FormInput from '../../components/Form/Input.vue';
|
import Input from 'dashboard/components-next/input/Input.vue';
|
||||||
import NextButton from 'dashboard/components-next/button/Button.vue';
|
import NextButton from 'dashboard/components-next/button/Button.vue';
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@@ -94,15 +94,16 @@ onMounted(async () => {
|
|||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<form class="space-y-5" method="POST" action="/api/v1/auth/saml_login">
|
<form class="space-y-5" method="POST" action="/api/v1/auth/saml_login">
|
||||||
<FormInput
|
<Input
|
||||||
v-model="credentials.email"
|
v-model="credentials.email"
|
||||||
name="email"
|
name="email"
|
||||||
type="text"
|
type="text"
|
||||||
|
autocomplete="email"
|
||||||
:tabindex="1"
|
:tabindex="1"
|
||||||
required
|
required
|
||||||
:label="t('LOGIN.SAML.WORK_EMAIL.LABEL')"
|
:label="t('LOGIN.SAML.WORK_EMAIL.LABEL')"
|
||||||
:placeholder="t('LOGIN.SAML.WORK_EMAIL.PLACEHOLDER')"
|
:placeholder="t('LOGIN.SAML.WORK_EMAIL.PLACEHOLDER')"
|
||||||
:has-error="v$.credentials.email.$error"
|
:message-type="v$.credentials.email.$error ? 'error' : ''"
|
||||||
@input="v$.credentials.email.$touch"
|
@input="v$.credentials.email.$touch"
|
||||||
/>
|
/>
|
||||||
<input
|
<input
|
||||||
|
|||||||
@@ -69,9 +69,13 @@
|
|||||||
description: 'Allow users to create new accounts from the dashboard'
|
description: 'Allow users to create new accounts from the dashboard'
|
||||||
locked: false
|
locked: false
|
||||||
- name: HCAPTCHA_SITE_KEY
|
- name: HCAPTCHA_SITE_KEY
|
||||||
|
display_title: 'HCaptcha Site Key'
|
||||||
|
description: 'The HCaptcha public key used in the signup page'
|
||||||
value:
|
value:
|
||||||
locked: false
|
locked: false
|
||||||
- name: HCAPTCHA_SERVER_KEY
|
- name: HCAPTCHA_SERVER_KEY
|
||||||
|
display_title: 'HCaptcha Server Key'
|
||||||
|
description: 'The HCaptcha server key used to validate the HCaptcha response'
|
||||||
value:
|
value:
|
||||||
locked: false
|
locked: false
|
||||||
- name: INSTALLATION_EVENTS_WEBHOOK_URL
|
- name: INSTALLATION_EVENTS_WEBHOOK_URL
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ module Enterprise::SuperAdmin::AppConfigsController
|
|||||||
def internal_config_options
|
def internal_config_options
|
||||||
%w[CHATWOOT_INBOX_TOKEN CHATWOOT_INBOX_HMAC_KEY ANALYTICS_TOKEN CLEARBIT_API_KEY DASHBOARD_SCRIPTS INACTIVE_WHATSAPP_NUMBERS BLOCKED_EMAIL_DOMAINS
|
%w[CHATWOOT_INBOX_TOKEN CHATWOOT_INBOX_HMAC_KEY ANALYTICS_TOKEN CLEARBIT_API_KEY DASHBOARD_SCRIPTS INACTIVE_WHATSAPP_NUMBERS BLOCKED_EMAIL_DOMAINS
|
||||||
SKIP_INCOMING_BCC_PROCESSING CAPTAIN_CLOUD_PLAN_LIMITS ACCOUNT_SECURITY_NOTIFICATION_WEBHOOK_URL CHATWOOT_INSTANCE_ADMIN_EMAIL
|
SKIP_INCOMING_BCC_PROCESSING CAPTAIN_CLOUD_PLAN_LIMITS ACCOUNT_SECURITY_NOTIFICATION_WEBHOOK_URL CHATWOOT_INSTANCE_ADMIN_EMAIL
|
||||||
OG_IMAGE_CDN_URL OG_IMAGE_CLIENT_REF CLOUDFLARE_API_KEY CLOUDFLARE_ZONE_ID]
|
OG_IMAGE_CDN_URL OG_IMAGE_CLIENT_REF CLOUDFLARE_API_KEY CLOUDFLARE_ZONE_ID HCAPTCHA_SITE_KEY HCAPTCHA_SERVER_KEY]
|
||||||
end
|
end
|
||||||
|
|
||||||
def captain_config_options
|
def captain_config_options
|
||||||
|
|||||||
Reference in New Issue
Block a user