From 96f7b057b016ccc9f7d71beadeaf85d2c41550ce Mon Sep 17 00:00:00 2001 From: JorgeLuisOZ Date: Tue, 3 Jun 2025 22:41:58 -0600 Subject: [PATCH] Cambios de parametros en registro de usuarios para el idioma --- public/css/login.css | 79 +++++++++++++++++++++++++++++++++++++------- public/index.html | 13 +++++++- public/register.html | 8 +++++ routes/auth.js | 10 +++--- routes/users.js | 5 ++- 5 files changed, 96 insertions(+), 19 deletions(-) diff --git a/public/css/login.css b/public/css/login.css index 3b5f8de..c84005e 100644 --- a/public/css/login.css +++ b/public/css/login.css @@ -1,13 +1,68 @@ +/* Fondo general */ body { - background: linear-gradient(to right, #6dd5fa, #2980b9); - height: 100vh; - display: flex; - justify-content: center; - align-items: center; - } - .card { - width: 100%; - max-width: 420px; - border-radius: 1rem; - box-shadow: 0 0 20px rgba(0,0,0,0.2); - } \ No newline at end of file + background: linear-gradient(to bottom right, #e0f7fa, #f1f8ff); + font-family: 'Segoe UI', sans-serif; +} + +/* Tarjeta del login */ +.card { + border-radius: 20px; + border: none; + background-color: #ffffffee; + 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 */ +} + diff --git a/public/index.html b/public/index.html index 5edc464..aabae11 100644 --- a/public/index.html +++ b/public/index.html @@ -6,6 +6,9 @@ + + + @@ -23,8 +26,16 @@ -
+
¿No tienes cuenta? Regístrate aquí +
+ + +
diff --git a/public/register.html b/public/register.html index ee50f55..3cc665c 100644 --- a/public/register.html +++ b/public/register.html @@ -36,6 +36,14 @@ +
+ + +
diff --git a/routes/auth.js b/routes/auth.js index 33239fd..081b80b 100644 --- a/routes/auth.js +++ b/routes/auth.js @@ -18,6 +18,7 @@ const userSchema = new mongoose.Schema({ email: { type: String, unique: true, required: true }, passwordHash: String, role: { type: String, enum: ['coach', 'athlete'], required: true }, + language: { type: String, default: 'es' }, // <- CAMPO AÑADIDO createdAt: { type: Date, default: Date.now } }); @@ -25,14 +26,14 @@ const User = mongoose.model('User', userSchema); // === Ruta: Registro de usuario === router.post('/register', async (req, res) => { - const { name, username, email, password, role } = req.body; + const { name, username, email, password, role, language } = req.body; try { const existing = await User.findOne({ email }); if (existing) return res.status(400).send('Correo ya registrado'); 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(); res.redirect('/index.html'); @@ -56,7 +57,8 @@ router.post('/login', async (req, res) => { res.json({ userId: user._id, name: user.name, - role: user.role + role: user.role, + language: user.language // <- También puedes enviar este dato al frontend }); } catch (error) { console.error('Error en login:', error); @@ -64,6 +66,4 @@ router.post('/login', async (req, res) => { } }); - - module.exports = router; diff --git a/routes/users.js b/routes/users.js index 327392b..b2fe061 100644 --- a/routes/users.js +++ b/routes/users.js @@ -29,7 +29,10 @@ router.get('/:id', async (req, res) => { await client.connect(); const db = client.db('swimartdb'); 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) { return res.status(404).json({ error: 'Usuario no encontrado' });