feat(auth): estrategia multicanal (WebControl + Google/Facebook + MariaDB Staff) y rediseño de login con mascota bot

This commit is contained in:
2026-10-20 15:35:43 -05:00
parent 72ce6adc12
commit f7cfccefa8
11 changed files with 694 additions and 133 deletions
+17 -3
View File
@@ -23,13 +23,27 @@ const User = {
);
return rows[0];
},
create: async (companyId, nombre, email, password, rol = 'client') => {
create: async (companyId, nombre, email, password, rol = 'client', provider = 'local', providerId = null, avatarUrl = null) => {
const [result] = await db.query(
'INSERT INTO users (company_id, nombre, email, password, rol) VALUES (?, ?, ?, ?, ?)',
[companyId, nombre, email, password, rol]
'INSERT INTO users (company_id, nombre, email, password, rol, provider, provider_id, avatar_url) VALUES (?, ?, ?, ?, ?, ?, ?, ?)',
[companyId, nombre, email, password, rol, provider, providerId, avatarUrl]
);
return result.insertId;
},
upsertExternal: async (nombre, email, provider, providerId, avatarUrl = null, companyId = 1) => {
const existing = await User.findByEmail(email);
if (existing) {
await User.update(existing.id, {
nombre: nombre || existing.nombre,
provider: provider || existing.provider,
provider_id: providerId || existing.provider_id,
avatar_url: avatarUrl || existing.avatar_url
});
return await User.findById(existing.id);
}
const insertId = await User.create(companyId, nombre, email, null, 'client', provider, providerId, avatarUrl);
return await User.findById(insertId);
},
update: async (id, data) => {
const fields = [];
const values = [];