Cambios de parametros en registro de usuarios para el idioma
This commit is contained in:
parent
5862c37c70
commit
96f7b057b0
|
@ -1,13 +1,68 @@
|
||||||
|
/* Fondo general */
|
||||||
body {
|
body {
|
||||||
background: linear-gradient(to right, #6dd5fa, #2980b9);
|
background: linear-gradient(to bottom right, #e0f7fa, #f1f8ff);
|
||||||
height: 100vh;
|
font-family: 'Segoe UI', sans-serif;
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Tarjeta del login */
|
||||||
.card {
|
.card {
|
||||||
width: 100%;
|
border-radius: 20px;
|
||||||
max-width: 420px;
|
border: none;
|
||||||
border-radius: 1rem;
|
background-color: #ffffffee;
|
||||||
box-shadow: 0 0 20px rgba(0,0,0,0.2);
|
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Título principal */
|
||||||
|
.card h3 {
|
||||||
|
font-weight: bold;
|
||||||
|
color: #0077b6;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Input y botones */
|
||||||
|
.form-control {
|
||||||
|
border-radius: 12px;
|
||||||
|
border: 1px solid #b0bec5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-control:focus {
|
||||||
|
border-color: #00bcd4;
|
||||||
|
box-shadow: 0 0 0 0.15rem rgba(0, 188, 212, 0.25);
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary {
|
||||||
|
background-color: #0077b6;
|
||||||
|
border: none;
|
||||||
|
border-radius: 12px;
|
||||||
|
transition: background-color 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary:hover {
|
||||||
|
background-color: #005f8c;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Idioma + Enlace de registro */
|
||||||
|
.text-center small {
|
||||||
|
font-size: 0.85rem;
|
||||||
|
color: #37474f;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: #0077b6;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
a:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Select de idioma */
|
||||||
|
#languageSelect {
|
||||||
|
border-radius: 999px;
|
||||||
|
background-color: #ffffff;
|
||||||
|
padding: 2px 10px;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
min-width: 90px; /* 👈 da espacio para el texto */
|
||||||
|
padding-right: 24px; /* 👈 da espacio para la flechita */
|
||||||
|
background-clip: padding-box; /* asegura que no se solape */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,9 @@
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<!-- Bootstrap CSS -->
|
<!-- Bootstrap CSS -->
|
||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<!-- Bootstrap Icons -->
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" href="css/login.css">
|
||||||
</head>
|
</head>
|
||||||
<body class="bg-light">
|
<body class="bg-light">
|
||||||
|
|
||||||
|
@ -23,8 +26,16 @@
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="btn btn-primary w-100">Ingresar</button>
|
<button type="submit" class="btn btn-primary w-100">Ingresar</button>
|
||||||
</form>
|
</form>
|
||||||
<div class="text-center mt-3">
|
<div class="text-center mt-3 d-flex justify-content-between align-items-center">
|
||||||
<small>¿No tienes cuenta? <a href="register.html">Regístrate aquí</a></small>
|
<small>¿No tienes cuenta? <a href="register.html">Regístrate aquí</a></small>
|
||||||
|
<div class="d-flex align-items-center ms-4"> <!-- ms-4 para separar del texto -->
|
||||||
|
<i class="bi bi-globe me-0"></i> <!-- me-0 para pegar el ícono al select -->
|
||||||
|
<select class="form-select form-select-sm border-0 shadow-none" id="languageSelect" style="width: auto;">
|
||||||
|
<option value="es">Español</option>
|
||||||
|
<option value="en">English</option>
|
||||||
|
<option value="fr">Français</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -36,6 +36,14 @@
|
||||||
<option value="athlete">Atleta</option>
|
<option value="athlete">Atleta</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="language" class="form-label">Idioma</label>
|
||||||
|
<select class="form-select" id="language" name="language" required>
|
||||||
|
<option value="es">Español</option>
|
||||||
|
<option value="en">Inglés</option>
|
||||||
|
<option value="fr">Francés</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
<button type="submit" class="btn btn-success w-100">Registrarse</button>
|
<button type="submit" class="btn btn-success w-100">Registrarse</button>
|
||||||
</form>
|
</form>
|
||||||
<div class="text-center mt-3">
|
<div class="text-center mt-3">
|
||||||
|
|
|
@ -18,6 +18,7 @@ const userSchema = new mongoose.Schema({
|
||||||
email: { type: String, unique: true, required: true },
|
email: { type: String, unique: true, required: true },
|
||||||
passwordHash: String,
|
passwordHash: String,
|
||||||
role: { type: String, enum: ['coach', 'athlete'], required: true },
|
role: { type: String, enum: ['coach', 'athlete'], required: true },
|
||||||
|
language: { type: String, default: 'es' }, // <- CAMPO AÑADIDO
|
||||||
createdAt: { type: Date, default: Date.now }
|
createdAt: { type: Date, default: Date.now }
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -25,14 +26,14 @@ const User = mongoose.model('User', userSchema);
|
||||||
|
|
||||||
// === Ruta: Registro de usuario ===
|
// === Ruta: Registro de usuario ===
|
||||||
router.post('/register', async (req, res) => {
|
router.post('/register', async (req, res) => {
|
||||||
const { name, username, email, password, role } = req.body;
|
const { name, username, email, password, role, language } = req.body;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const existing = await User.findOne({ email });
|
const existing = await User.findOne({ email });
|
||||||
if (existing) return res.status(400).send('Correo ya registrado');
|
if (existing) return res.status(400).send('Correo ya registrado');
|
||||||
|
|
||||||
const passwordHash = await bcrypt.hash(password, 10);
|
const passwordHash = await bcrypt.hash(password, 10);
|
||||||
const user = new User({ name, username, email, passwordHash, role });
|
const user = new User({ name, username, email, passwordHash, role, language });
|
||||||
await user.save();
|
await user.save();
|
||||||
|
|
||||||
res.redirect('/index.html');
|
res.redirect('/index.html');
|
||||||
|
@ -56,7 +57,8 @@ router.post('/login', async (req, res) => {
|
||||||
res.json({
|
res.json({
|
||||||
userId: user._id,
|
userId: user._id,
|
||||||
name: user.name,
|
name: user.name,
|
||||||
role: user.role
|
role: user.role,
|
||||||
|
language: user.language // <- También puedes enviar este dato al frontend
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error en login:', error);
|
console.error('Error en login:', error);
|
||||||
|
@ -64,6 +66,4 @@ router.post('/login', async (req, res) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|
|
@ -29,7 +29,10 @@ router.get('/:id', async (req, res) => {
|
||||||
await client.connect();
|
await client.connect();
|
||||||
const db = client.db('swimartdb');
|
const db = client.db('swimartdb');
|
||||||
const user = await db.collection('users')
|
const user = await db.collection('users')
|
||||||
.findOne({ _id: new ObjectId(req.params.id) }, { projection: { name: 1, email: 1, role: 1 } });
|
.findOne(
|
||||||
|
{ _id: new ObjectId(req.params.id) },
|
||||||
|
{ projection: { name: 1, email: 1, role: 1, language: 1 } } // ← aquí se añade
|
||||||
|
);
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
return res.status(404).json({ error: 'Usuario no encontrado' });
|
return res.status(404).json({ error: 'Usuario no encontrado' });
|
||||||
|
|
Loading…
Reference in New Issue