fix: seed demo users for doctor and pharmacy to fix 401 on login
Build Curio HMS / build-and-deploy (push) Successful in 1m10s
Details
Build Curio HMS / build-and-deploy (push) Successful in 1m10s
Details
This commit is contained in:
parent
1559e9f505
commit
4a5ea663b6
|
|
@ -134,6 +134,27 @@ async function seedSuperAdmin() {
|
||||||
console.log(`[DB] Super admin seeded: ${email}`);
|
console.log(`[DB] Super admin seeded: ${email}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function seedDemoUsers() {
|
||||||
|
const defaultPassword = 'password';
|
||||||
|
const hash = await bcrypt.hash(defaultPassword, 10);
|
||||||
|
const demoUsers = [
|
||||||
|
{ email: 'doctor@curio.app', name: 'Dr. Sharma', role: 'DOCTOR', tenant_id: 'default' },
|
||||||
|
{ email: 'pharmacy@curio.app', name: 'Pharmacist', role: 'PHARMACIST', tenant_id: 'default' },
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const u of demoUsers) {
|
||||||
|
const existing = await pool.query('SELECT id FROM users WHERE email = $1', [u.email]);
|
||||||
|
if (existing.rows.length === 0) {
|
||||||
|
await pool.query(
|
||||||
|
`INSERT INTO users (tenant_id, email, password_hash, name, role)
|
||||||
|
VALUES ($1, $2, $3, $4, $5)`,
|
||||||
|
[u.tenant_id, u.email, hash, u.name, u.role]
|
||||||
|
);
|
||||||
|
console.log(`[DB] Demo user seeded: ${u.email}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ── Seed legacy in-memory tenants into DB ─────────────────────────────────────
|
// ── Seed legacy in-memory tenants into DB ─────────────────────────────────────
|
||||||
|
|
||||||
async function seedLegacyTenants() {
|
async function seedLegacyTenants() {
|
||||||
|
|
@ -192,6 +213,7 @@ async function initSchema() {
|
||||||
console.log('[DB] Schema ready.');
|
console.log('[DB] Schema ready.');
|
||||||
await seedSuperAdmin();
|
await seedSuperAdmin();
|
||||||
await seedLegacyTenants();
|
await seedLegacyTenants();
|
||||||
|
await seedDemoUsers();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('[DB] Schema init failed:', err.message);
|
console.error('[DB] Schema init failed:', err.message);
|
||||||
// Don't crash — let server start even if DB is temporarily unavailable
|
// Don't crash — let server start even if DB is temporarily unavailable
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,9 @@
|
||||||
|
|
||||||
<p class="auth-footer">New to Curio? <a href="register.html">Register your clinic</a></p>
|
<p class="auth-footer">New to Curio? <a href="register.html">Register your clinic</a></p>
|
||||||
<p class="auth-footer" style="font-size:0.78rem; color: var(--text-muted);">
|
<p class="auth-footer" style="font-size:0.78rem; color: var(--text-muted);">
|
||||||
Demo: <code>admin@curio.app</code> / <code>superadmin</code>
|
Demo Admin: <code>admin@curio.app</code> / <code>superadmin</code><br>
|
||||||
|
Demo Doctor: <code>doctor@curio.app</code> / <code>password</code><br>
|
||||||
|
Demo Pharmacy: <code>pharmacy@curio.app</code> / <code>password</code>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue