Fix jwt-token
This commit is contained in:
@@ -340,7 +340,7 @@ const MapView = () => {
|
||||
onChange={(e) => setShowDroneDetections(e.target.checked)}
|
||||
className="rounded border-gray-300 text-primary-600 focus:ring-primary-500"
|
||||
/>
|
||||
<span className="text-sm text-gray-700">Show Drone Detections</span>
|
||||
<span className="text-sm text-gray-700">{t('map.showDroneDetections')}</span>
|
||||
</label>
|
||||
|
||||
{droneDetectionHistory.length > 0 && (
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { Navigate, Link } from 'react-router-dom';
|
||||
import { useAuth } from '../contexts/AuthContext';
|
||||
import { useTranslation } from '../utils/tempTranslations';
|
||||
import { EyeIcon, EyeSlashIcon } from '@heroicons/react/24/outline';
|
||||
import toast from 'react-hot-toast';
|
||||
import api from '../services/api';
|
||||
|
||||
const Register = () => {
|
||||
const { t } = useTranslation();
|
||||
const [formData, setFormData] = useState({
|
||||
username: '',
|
||||
email: '',
|
||||
@@ -31,11 +33,11 @@ const Register = () => {
|
||||
|
||||
// Security check: If registration is not enabled, show error
|
||||
if (!response.data.data?.features?.registration) {
|
||||
toast.error('Registration is not enabled for this tenant');
|
||||
toast.error(t('register.registrationDisabled'));
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch tenant config:', error);
|
||||
toast.error('Failed to load authentication configuration');
|
||||
toast.error(t('register.configLoadFailed'));
|
||||
} finally {
|
||||
setConfigLoading(false);
|
||||
}
|
||||
@@ -124,38 +126,38 @@ const Register = () => {
|
||||
|
||||
// Validation
|
||||
if (!formData.username || !formData.email || !formData.password) {
|
||||
toast.error('Please fill in all required fields');
|
||||
toast.error(t('register.fillAllFields'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (formData.password !== formData.confirmPassword) {
|
||||
toast.error('Passwords do not match');
|
||||
toast.error(t('register.passwordsMismatch'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (formData.password.length < 8) {
|
||||
toast.error('Password must be at least 8 characters long');
|
||||
toast.error(t('register.passwordTooShort'));
|
||||
return;
|
||||
}
|
||||
|
||||
// Strong password validation
|
||||
const passwordRegex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)/;
|
||||
if (!passwordRegex.test(formData.password)) {
|
||||
toast.error('Password must contain at least one lowercase letter, one uppercase letter, and one number');
|
||||
toast.error(t('register.passwordRequirements'));
|
||||
return;
|
||||
}
|
||||
|
||||
// Username validation
|
||||
const usernameRegex = /^[a-zA-Z0-9._-]+$/;
|
||||
if (!usernameRegex.test(formData.username)) {
|
||||
toast.error('Username can only contain letters, numbers, dots, underscores, and hyphens');
|
||||
toast.error(t('register.usernameInvalid'));
|
||||
return;
|
||||
}
|
||||
|
||||
// Email validation
|
||||
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
||||
if (!emailRegex.test(formData.email)) {
|
||||
toast.error('Please enter a valid email address');
|
||||
toast.error(t('register.emailInvalid'));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -163,7 +165,7 @@ const Register = () => {
|
||||
if (formData.phone_number) {
|
||||
const phoneRegex = /^[\+]?[1-9][\d]{0,15}$/;
|
||||
if (!phoneRegex.test(formData.phone_number.replace(/[\s\-\(\)]/g, ''))) {
|
||||
toast.error('Please enter a valid phone number');
|
||||
toast.error(t('register.phoneInvalid'));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user