12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- function sendVerificationCode(email) {
- if (!email.includes('@gmail.com')) {
- document.getElementById('errorMessage').textContent = 'Пожалуйста, введите адрес электронной почты Gmail.';
- document.getElementById('errorPopup').style.display = 'block';
- return;
- }
- fetch('/send_code', {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json'
- },
- body: JSON.stringify({ email: email })
- })
- .then(response => {
- if (response.ok) {
- // Код успешно отправлен
- alert('Код отправлен на вашу почту!');
- } else {
- // Ошибка отправки кода
- document.getElementById('errorMessage').textContent = 'Ошибка отправки кода!';
- document.getElementById('errorPopup').style.display = 'block';
- }
- })
- .catch(error => {
- // Ошибка связи с сервером
- document.getElementById('errorMessage').textContent = 'Ошибка сервера!';
- document.getElementById('errorPopup').style.display = 'block';
- });
- }
- function registerUser(name, phone, email, code, password) {
- fetch('/register', {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json'
- },
- body: JSON.stringify({ name: name, phone: phone, email: email, code: code, password: password })
- })
- .then(response => {
- if (response.ok) {
- // Регистрация успешна
- document.getElementById('successPopup').style.display = 'block';
- } else {
- // Ошибка регистрации
- document.getElementById('errorMessage').textContent = 'Ошибка регистрации!';
- document.getElementById('errorPopup').style.display = 'block';
- }
- })
- .catch(error => {
- // Ошибка связи с сервером
- document.getElementById('errorMessage').textContent = 'Ошибка сервера!';
- document.getElementById('errorPopup').style.display = 'block';
- });
- }
|