фикс
This commit is contained in:
parent
404091563a
commit
5a485de698
@ -23,6 +23,21 @@ const registerUser = async (req, res, next) => {
|
||||
throw new Error('Пожалуйста, заполните все обязательные поля: имя, email, пароль и дату рождения.');
|
||||
}
|
||||
|
||||
// Проверка возраста (минимум 14 лет)
|
||||
const birthDate = new Date(dateOfBirth);
|
||||
const today = new Date();
|
||||
let age = today.getFullYear() - birthDate.getFullYear();
|
||||
const monthDiff = today.getMonth() - birthDate.getMonth();
|
||||
|
||||
if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birthDate.getDate())) {
|
||||
age--;
|
||||
}
|
||||
|
||||
if (age < 14) {
|
||||
res.status(400);
|
||||
throw new Error('Для регистрации необходим возраст не менее 14 лет.');
|
||||
}
|
||||
|
||||
const normalizedEmail = email.toLowerCase();
|
||||
console.log('Нормализованный email для поиска:', normalizedEmail);
|
||||
|
||||
|
@ -52,15 +52,19 @@
|
||||
<i class="bi-calendar"></i>
|
||||
Дата рождения
|
||||
</label>
|
||||
<input
|
||||
type="date"
|
||||
id="birthdate"
|
||||
v-model="birthdate"
|
||||
required
|
||||
:disabled="loading"
|
||||
:max="maxDate"
|
||||
class="date-input"
|
||||
/>
|
||||
<div class="date-input-container">
|
||||
<input
|
||||
type="date"
|
||||
id="birthdate"
|
||||
v-model="birthdate"
|
||||
required
|
||||
:disabled="loading"
|
||||
:max="maxDate"
|
||||
class="date-input"
|
||||
ref="birthdateInput"
|
||||
@click="openDatePicker"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
@ -136,11 +140,19 @@ const password = ref('');
|
||||
const confirmPassword = ref('');
|
||||
const errorMessage = ref('');
|
||||
const loading = ref(false);
|
||||
const birthdateInput = ref(null);
|
||||
|
||||
// Вычисляем максимальную дату (минимальный возраст 18 лет)
|
||||
// Функция для открытия календаря при клике на поле
|
||||
const openDatePicker = () => {
|
||||
if (birthdateInput.value && typeof birthdateInput.value.showPicker === 'function') {
|
||||
birthdateInput.value.showPicker();
|
||||
}
|
||||
};
|
||||
|
||||
// Вычисляем максимальную дату (минимальный возраст 14 лет)
|
||||
const maxDate = computed(() => {
|
||||
const date = new Date();
|
||||
date.setFullYear(date.getFullYear() - 18);
|
||||
date.setFullYear(date.getFullYear() - 14);
|
||||
return date.toISOString().split('T')[0];
|
||||
});
|
||||
|
||||
@ -191,7 +203,7 @@ const handleRegister = async () => {
|
||||
return;
|
||||
}
|
||||
|
||||
// Проверяем возраст (минимум 18 лет)
|
||||
// Проверяем возраст (минимум 14 лет)
|
||||
const birthDate = new Date(birthdate.value);
|
||||
const today = new Date();
|
||||
let age = today.getFullYear() - birthDate.getFullYear();
|
||||
@ -201,8 +213,8 @@ const handleRegister = async () => {
|
||||
age--;
|
||||
}
|
||||
|
||||
if (age < 18) {
|
||||
errorMessage.value = 'Вам должно быть не менее 18 лет для регистрации.';
|
||||
if (age < 14) {
|
||||
errorMessage.value = 'Вам должно быть не менее 14 лет для регистрации.';
|
||||
loading.value = false;
|
||||
return;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user