2019-08-14 09:48:44 +00:00
|
|
|
<template>
|
|
|
|
<div class="medium-10 column signup">
|
2019-10-05 08:34:24 +00:00
|
|
|
<div class="text-center medium-12 signup--hero">
|
2019-08-25 14:29:28 +00:00
|
|
|
<img
|
2020-05-11 20:01:40 +00:00
|
|
|
:src="globalConfig.logo"
|
|
|
|
:alt="globalConfig.installationName"
|
2019-10-05 08:34:24 +00:00
|
|
|
class="hero--logo"
|
2019-08-25 14:29:28 +00:00
|
|
|
/>
|
2019-10-05 08:34:24 +00:00
|
|
|
<h2 class="hero--title">
|
2019-08-25 14:29:28 +00:00
|
|
|
{{ $t('REGISTER.TRY_WOOT') }}
|
|
|
|
</h2>
|
2019-08-14 09:48:44 +00:00
|
|
|
</div>
|
|
|
|
<div class="row align-center">
|
2020-12-21 08:35:19 +00:00
|
|
|
<div class="small-12 medium-6 large-5 column">
|
|
|
|
<form class="signup--box login-box" @submit.prevent="submit">
|
|
|
|
<woot-input
|
|
|
|
v-model="credentials.fullName"
|
|
|
|
:class="{ error: $v.credentials.fullName.$error }"
|
|
|
|
:label="$t('REGISTER.FULL_NAME.LABEL')"
|
|
|
|
:placeholder="$t('REGISTER.FULL_NAME.PLACEHOLDER')"
|
|
|
|
:error="
|
|
|
|
$v.credentials.fullName.$error
|
|
|
|
? $t('REGISTER.FULL_NAME.ERROR')
|
|
|
|
: ''
|
|
|
|
"
|
|
|
|
@blur="$v.credentials.fullName.$touch"
|
|
|
|
/>
|
2021-06-07 11:56:08 +00:00
|
|
|
<woot-input
|
|
|
|
v-model.trim="credentials.email"
|
|
|
|
type="email"
|
|
|
|
:class="{ error: $v.credentials.email.$error }"
|
|
|
|
:label="$t('REGISTER.EMAIL.LABEL')"
|
|
|
|
:placeholder="$t('REGISTER.EMAIL.PLACEHOLDER')"
|
|
|
|
:error="
|
|
|
|
$v.credentials.email.$error ? $t('REGISTER.EMAIL.ERROR') : ''
|
|
|
|
"
|
|
|
|
@blur="$v.credentials.email.$touch"
|
|
|
|
/>
|
2020-12-21 08:35:19 +00:00
|
|
|
<woot-input
|
|
|
|
v-model="credentials.accountName"
|
|
|
|
:class="{ error: $v.credentials.accountName.$error }"
|
|
|
|
:label="$t('REGISTER.ACCOUNT_NAME.LABEL')"
|
|
|
|
:placeholder="$t('REGISTER.ACCOUNT_NAME.PLACEHOLDER')"
|
|
|
|
:error="
|
|
|
|
$v.credentials.accountName.$error
|
|
|
|
? $t('REGISTER.ACCOUNT_NAME.ERROR')
|
|
|
|
: ''
|
|
|
|
"
|
|
|
|
@blur="$v.credentials.accountName.$touch"
|
|
|
|
/>
|
|
|
|
<woot-input
|
2021-06-07 11:56:08 +00:00
|
|
|
v-model.trim="credentials.password"
|
|
|
|
type="password"
|
|
|
|
:class="{ error: $v.credentials.password.$error }"
|
|
|
|
:label="$t('LOGIN.PASSWORD.LABEL')"
|
|
|
|
:placeholder="$t('SET_NEW_PASSWORD.PASSWORD.PLACEHOLDER')"
|
2020-12-21 08:35:19 +00:00
|
|
|
:error="
|
2021-06-07 11:56:08 +00:00
|
|
|
$v.credentials.password.$error
|
|
|
|
? $t('SET_NEW_PASSWORD.PASSWORD.ERROR')
|
|
|
|
: ''
|
2020-12-21 08:35:19 +00:00
|
|
|
"
|
2021-06-07 11:56:08 +00:00
|
|
|
@blur="$v.credentials.password.$touch"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<woot-input
|
|
|
|
v-model.trim="credentials.confirmPassword"
|
|
|
|
type="password"
|
|
|
|
:class="{ error: $v.credentials.confirmPassword.$error }"
|
|
|
|
:label="$t('SET_NEW_PASSWORD.CONFIRM_PASSWORD.LABEL')"
|
|
|
|
:placeholder="$t('SET_NEW_PASSWORD.CONFIRM_PASSWORD.PLACEHOLDER')"
|
|
|
|
:error="
|
|
|
|
$v.credentials.confirmPassword.$error
|
|
|
|
? $t('SET_NEW_PASSWORD.CONFIRM_PASSWORD.ERROR')
|
|
|
|
: ''
|
|
|
|
"
|
|
|
|
@blur="$v.credentials.confirmPassword.$touch"
|
2020-12-21 08:35:19 +00:00
|
|
|
/>
|
2022-02-18 14:32:50 +00:00
|
|
|
<div v-if="globalConfig.hCaptchaSiteKey" class="h-captcha--box">
|
|
|
|
<vue-hcaptcha
|
|
|
|
:sitekey="globalConfig.hCaptchaSiteKey"
|
|
|
|
@verify="onRecaptchaVerified"
|
|
|
|
/>
|
|
|
|
</div>
|
2020-12-21 08:35:19 +00:00
|
|
|
<woot-submit-button
|
2022-02-18 14:32:50 +00:00
|
|
|
:disabled="isSignupInProgress || !hasAValidCaptcha"
|
2020-12-21 08:35:19 +00:00
|
|
|
:button-text="$t('REGISTER.SUBMIT')"
|
|
|
|
:loading="isSignupInProgress"
|
|
|
|
button-class="large expanded"
|
|
|
|
>
|
|
|
|
</woot-submit-button>
|
|
|
|
<p class="accept--terms" v-html="termsLink"></p>
|
2019-08-14 09:48:44 +00:00
|
|
|
</form>
|
2019-10-05 08:34:24 +00:00
|
|
|
<div class="column text-center sigin--footer">
|
2020-12-21 08:35:19 +00:00
|
|
|
<span>{{ $t('REGISTER.HAVE_AN_ACCOUNT') }}</span>
|
2020-03-09 17:57:10 +00:00
|
|
|
<router-link to="/app/login">
|
2020-05-11 20:01:40 +00:00
|
|
|
{{
|
|
|
|
useInstallationName(
|
|
|
|
$t('LOGIN.TITLE'),
|
|
|
|
globalConfig.installationName
|
|
|
|
)
|
|
|
|
}}
|
2019-08-14 09:48:44 +00:00
|
|
|
</router-link>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { required, minLength, email } from 'vuelidate/lib/validators';
|
|
|
|
import Auth from '../../api/auth';
|
2020-05-11 20:01:40 +00:00
|
|
|
import { mapGetters } from 'vuex';
|
|
|
|
import globalConfigMixin from 'shared/mixins/globalConfigMixin';
|
2020-12-21 08:35:19 +00:00
|
|
|
import alertMixin from 'shared/mixins/alertMixin';
|
2021-05-28 13:51:16 +00:00
|
|
|
import { DEFAULT_REDIRECT_URL } from '../../constants';
|
2022-02-18 14:32:50 +00:00
|
|
|
import VueHcaptcha from '@hcaptcha/vue-hcaptcha';
|
2019-08-14 09:48:44 +00:00
|
|
|
export default {
|
2022-02-18 14:32:50 +00:00
|
|
|
components: {
|
|
|
|
VueHcaptcha,
|
|
|
|
},
|
2020-12-21 08:35:19 +00:00
|
|
|
mixins: [globalConfigMixin, alertMixin],
|
2019-08-14 09:48:44 +00:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
credentials: {
|
2020-12-21 08:35:19 +00:00
|
|
|
accountName: '',
|
|
|
|
fullName: '',
|
2019-08-14 09:48:44 +00:00
|
|
|
email: '',
|
2021-06-07 11:56:08 +00:00
|
|
|
password: '',
|
|
|
|
confirmPassword: '',
|
2022-02-18 14:32:50 +00:00
|
|
|
hCaptchaClientResponse: '',
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
2020-12-21 08:35:19 +00:00
|
|
|
isSignupInProgress: false,
|
2019-08-14 09:48:44 +00:00
|
|
|
error: '',
|
|
|
|
};
|
|
|
|
},
|
|
|
|
validations: {
|
|
|
|
credentials: {
|
2020-12-21 08:35:19 +00:00
|
|
|
accountName: {
|
|
|
|
required,
|
|
|
|
minLength: minLength(2),
|
|
|
|
},
|
|
|
|
fullName: {
|
2019-08-14 09:48:44 +00:00
|
|
|
required,
|
2020-12-21 08:35:19 +00:00
|
|
|
minLength: minLength(2),
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
email: {
|
|
|
|
required,
|
|
|
|
email,
|
|
|
|
},
|
2021-06-07 11:56:08 +00:00
|
|
|
password: {
|
|
|
|
required,
|
|
|
|
minLength: minLength(6),
|
|
|
|
},
|
|
|
|
confirmPassword: {
|
|
|
|
required,
|
|
|
|
isEqPassword(value) {
|
|
|
|
if (value !== this.credentials.password) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
},
|
2020-05-11 20:01:40 +00:00
|
|
|
computed: {
|
2022-02-18 14:32:50 +00:00
|
|
|
...mapGetters({ globalConfig: 'globalConfig/get' }),
|
2020-05-11 20:01:40 +00:00
|
|
|
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
|
|
|
|
);
|
|
|
|
},
|
2022-02-18 14:32:50 +00:00
|
|
|
hasAValidCaptcha() {
|
|
|
|
if (this.globalConfig.hCaptchaSiteKey) {
|
|
|
|
return !!this.credentials.hCaptchaClientResponse;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
},
|
2020-05-11 20:01:40 +00:00
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
methods: {
|
2020-12-21 08:35:19 +00:00
|
|
|
async submit() {
|
|
|
|
this.$v.$touch();
|
|
|
|
if (this.$v.$invalid) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.isSignupInProgress = true;
|
|
|
|
try {
|
|
|
|
const response = await Auth.register(this.credentials);
|
|
|
|
if (response.status === 200) {
|
2021-05-28 13:51:16 +00:00
|
|
|
window.location = DEFAULT_REDIRECT_URL;
|
2020-12-21 08:35:19 +00:00
|
|
|
}
|
|
|
|
} catch (error) {
|
|
|
|
let errorMessage = this.$t('REGISTER.API.ERROR_MESSAGE');
|
|
|
|
if (error.response && error.response.data.message) {
|
|
|
|
errorMessage = error.response.data.message;
|
|
|
|
}
|
|
|
|
this.showAlert(errorMessage);
|
|
|
|
} finally {
|
|
|
|
this.isSignupInProgress = false;
|
|
|
|
}
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
2022-02-18 14:32:50 +00:00
|
|
|
onRecaptchaVerified(token) {
|
|
|
|
this.credentials.hCaptchaClientResponse = token;
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
2020-12-21 08:35:19 +00:00
|
|
|
<style scoped lang="scss">
|
|
|
|
.signup {
|
|
|
|
.signup--hero {
|
|
|
|
margin-bottom: var(--space-larger);
|
|
|
|
|
|
|
|
.hero--logo {
|
|
|
|
width: 180px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.hero--title {
|
|
|
|
margin-top: var(--space-large);
|
|
|
|
font-weight: var(--font-weight-light);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.signup--box {
|
|
|
|
padding: var(--space-large);
|
|
|
|
|
|
|
|
label {
|
|
|
|
font-size: var(--font-size-default);
|
|
|
|
color: var(--b-600);
|
|
|
|
|
|
|
|
input {
|
|
|
|
padding: var(--space-slab);
|
|
|
|
height: var(--space-larger);
|
|
|
|
font-size: var(--font-size-default);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.sigin--footer {
|
|
|
|
padding: var(--space-medium);
|
|
|
|
font-size: var(--font-size-default);
|
|
|
|
|
|
|
|
> a {
|
|
|
|
font-weight: var(--font-weight-bold);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.accept--terms {
|
|
|
|
font-size: var(--font-size-small);
|
|
|
|
text-align: center;
|
|
|
|
margin: var(--space-normal) 0 0 0;
|
|
|
|
}
|
2022-02-18 14:32:50 +00:00
|
|
|
|
|
|
|
.h-captcha--box {
|
|
|
|
margin-bottom: var(--space-one);
|
|
|
|
}
|
2020-12-21 08:35:19 +00:00
|
|
|
}
|
|
|
|
</style>
|