parent
60dea511b9
commit
30f3a51ef8
@ -27,23 +27,25 @@
|
|||||||
<span class="font-bold">*</span>
|
<span class="font-bold">*</span>
|
||||||
</label>
|
</label>
|
||||||
<input
|
<input
|
||||||
v-model="userdetails.mail"
|
v-model="user_email"
|
||||||
name="email_address"
|
name="email_address"
|
||||||
id="email_address"
|
id="email_address"
|
||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
:placeholder="[[$t('e_mail_adress')]]"
|
:placeholder="[[$t('e_mail_adress')]]"
|
||||||
type="email"
|
type="email"
|
||||||
:class="{ 'border-red-500': (!isEmail(userdetails.mail)), 'border-green-300': (isEmail(userdetails.mail)) }"
|
:class="{ 'border-red-500': (!isEmail(user_email)), 'border-green-300': (isEmail(user_email)) }"
|
||||||
class="dark:bg-gray-800 mt-1 block w-full shadow-sm sm:text-sm border-2 bg-gray-50 text-gray-500 rounded-md p-2"
|
class="dark:bg-gray-800 mt-1 block w-full shadow-sm sm:text-sm border-2 bg-gray-50 text-gray-500 rounded-md p-2"
|
||||||
/>
|
/>
|
||||||
<p
|
<p
|
||||||
v-if="!isEmail(userdetails.mail)"
|
v-if="!isEmail(user_email)"
|
||||||
class="text-sm"
|
class="text-sm"
|
||||||
>{{ $t('please_provide_valid_mail') }}</p>
|
>{{ $t('please_provide_valid_mail') }}</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-2">
|
<div class="mt-2">
|
||||||
<a
|
<a
|
||||||
href="./login"
|
:disabled="(!state.submit_enabled)"
|
||||||
|
:class="{ 'opacity-50': (!state.submit_enabled), 'cursor-not-allowed': (!state.submit_enabled) }"
|
||||||
|
@click="resendMail"
|
||||||
class="block w-full text-center py-2 px-3 border-2 border-gray-300 rounded-md p-1 dark:bg-gray-800 font-medium hover:border-gray-400 focus:outline-none focus:border-gray-400 sm:text-sm"
|
class="block w-full text-center py-2 px-3 border-2 border-gray-300 rounded-md p-1 dark:bg-gray-800 font-medium hover:border-gray-400 focus:outline-none focus:border-gray-400 sm:text-sm"
|
||||||
>{{ $t('resend_the_registration_mail') }}</a>
|
>{{ $t('resend_the_registration_mail') }}</a>
|
||||||
</div>
|
</div>
|
||||||
@ -76,77 +78,44 @@ import isMobilePhone from 'validator/es/lib/isMobilePhone';
|
|||||||
import isPostalCode from 'validator/es/lib/isPostalCode';
|
import isPostalCode from 'validator/es/lib/isPostalCode';
|
||||||
import { useToast } from "vue-toastification";
|
import { useToast } from "vue-toastification";
|
||||||
|
|
||||||
const props = defineProps({
|
// const props = defineProps({
|
||||||
token: String
|
// token: String
|
||||||
})
|
// })
|
||||||
if (props.token) {
|
// if (props.token) {
|
||||||
axios.get(`${config.baseurl}api/organizations/selfservice/${props.token}`)
|
// axios.get(`${config.baseurl}api/organizations/selfservice/${props.token}`)
|
||||||
.then(({ data }) => {
|
// .then(({ data }) => {
|
||||||
state.org_name = data.name;
|
// state.org_name = data.name;
|
||||||
state.org_teams = data.teams;
|
// state.org_teams = data.teams;
|
||||||
org_team.value = data.teams[0]?.id;
|
// org_team.value = data.teams[0]?.id;
|
||||||
})
|
// })
|
||||||
.catch((error) => {
|
// .catch((error) => {
|
||||||
console.log(error);
|
// console.log(error);
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
|
||||||
let userdetails = ref({ firstname: "", lastname: "", middlename: "", mail: "", phone: "", address: { street: "", address2: "", city: "", zipcode: "" } });
|
let user_email = ref("");
|
||||||
let provide_address = ref(false);
|
|
||||||
let agb_accepted = ref(false);
|
|
||||||
let data_confirmed = ref(false);
|
|
||||||
let org_team = ref("");
|
|
||||||
//
|
//
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
org_name: "",
|
org_name: "",
|
||||||
org_teams: [],
|
org_teams: [],
|
||||||
submit_enabled: computed(() => agb_accepted.value === true && data_confirmed.value === true && (isMobilePhone(userdetails.value.phone) || !userdetails.value.phone.trim()) && isEmail(userdetails.value.mail)
|
submit_enabled: computed(() => isEmail(user_email.value))
|
||||||
&& userdetails.value.firstname
|
|
||||||
&& userdetails.value.lastname && (provide_address.value === false || provide_address.value === true && (userdetails.value.address.street.trim() && userdetails.value.address.city.trim() && isPostalCode(userdetails.value.address.zipcode, "DE"))))
|
|
||||||
})
|
})
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
function login() {
|
function resendMail() {
|
||||||
userdetails = userdetails.value;
|
if (isEmail(user_email.value)) {
|
||||||
if (userdetails.phone === "" || isMobilePhone(userdetails.phone)) {
|
toast("sending password reset mail...");
|
||||||
if (isEmail(userdetails.mail)) {
|
|
||||||
let postdata = {
|
|
||||||
"email": userdetails.mail,
|
|
||||||
"firstname": userdetails.firstname,
|
|
||||||
"middlename": userdetails.middlename,
|
|
||||||
"lastname": userdetails.lastname,
|
|
||||||
"address": {}
|
|
||||||
}
|
|
||||||
if (isMobilePhone(userdetails.phone)) {
|
|
||||||
postdata.phone = userdetails.phone;
|
|
||||||
}
|
|
||||||
if (provide_address.value === true) {
|
|
||||||
postdata.address = {
|
|
||||||
address1: userdetails.address.street,
|
|
||||||
address2: userdetails.address.address2 || "",
|
|
||||||
city: userdetails.address.city,
|
|
||||||
postalcode: userdetails.address.zipcode,
|
|
||||||
country: "DE",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (state.org_name !== '' && state.org_teams.length > 0) {
|
|
||||||
postdata.team = org_team.value;
|
|
||||||
}
|
|
||||||
toast("registration in progress...");
|
|
||||||
const browserlocale = ((navigator.languages && navigator.languages[0]) || '').substr(0, 2);
|
const browserlocale = ((navigator.languages && navigator.languages[0]) || '').substr(0, 2);
|
||||||
let url = `${config.baseurl}api/runners/register/?locale=${browserlocale}`;
|
axios.post(`${config.baseurl}api/runners/forgot/?locale=${browserlocale}`, {
|
||||||
if (props.token) {
|
"mail": user_email.value
|
||||||
url = `${config.baseurl}api/runners/register/${props.token}/?locale=${browserlocale}`
|
})
|
||||||
}
|
|
||||||
axios.post(url, postdata)
|
|
||||||
.then(({ data }) => {
|
.then(({ data }) => {
|
||||||
const token = btoa(data.token);
|
console.log(data);
|
||||||
// alert(token);
|
toast("sent password reset mail to " + user_email.value + "!");
|
||||||
location.replace(`${config.baseurl_selfservice}profile/${token}`);
|
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
|
toast("user does not exist...");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
Loading…
x
Reference in New Issue
Block a user