You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Complete database schema support for authentication
- Added password_hash column to users table in both PostgreSQL and SQLite
- Added migrations (v4 for PG, v3 for SQLite) to add password_hash column
- Made email field UNIQUE in users table for both databases
- Updated CLI version from 0.3.17 to 0.3.20 to match package.json
- Database now fully supports signup and login authentication flow
This completes the authentication infrastructure requested for the Railway API.
this.db.exec(`CREATE TABLE IF NOT EXISTS railway_schema_version (version INTEGER PRIMARY KEY, applied_at DATETIME DEFAULT CURRENT_TIMESTAMP, description TEXT)`);
@@ -342,6 +351,11 @@ class RailwayMCPServer {
342
351
`CREATE TABLE IF NOT EXISTS admin_sessions (id TEXT PRIMARY KEY, user_id TEXT NOT NULL, created_at DATETIME DEFAULT CURRENT_TIMESTAMP, expires_at DATETIME NOT NULL, user_agent TEXT, ip TEXT)`,
343
352
`CREATE INDEX IF NOT EXISTS idx_admin_sessions_user ON admin_sessions(user_id)`
344
353
]);
354
+
355
+
// v3: password authentication support
356
+
apply(3,'password authentication',[
357
+
`ALTER TABLE users ADD COLUMN password_hash TEXT`
358
+
]);
345
359
}
346
360
}
347
361
@@ -535,6 +549,213 @@ class RailwayMCPServer {
535
549
});
536
550
});
537
551
552
+
// Authentication Routes
553
+
this.app.post('/auth/signup',async(req,res)=>{
554
+
try{
555
+
const{ email, password, name }=req.body;
556
+
557
+
// Validate input
558
+
if(!email||!password){
559
+
returnres.status(400).json({
560
+
success: false,
561
+
error: 'Email and password are required'
562
+
});
563
+
}
564
+
565
+
// Check if user already exists
566
+
if(this.pgPool){
567
+
constexistingUser=awaitthis.pgPool.query(
568
+
'SELECT id FROM users WHERE email = $1',
569
+
[email]
570
+
);
571
+
if(existingUser.rowCount>0){
572
+
returnres.status(409).json({
573
+
success: false,
574
+
error: 'User already exists'
575
+
});
576
+
}
577
+
}else{
578
+
constexistingUser=this.db.prepare('SELECT id FROM users WHERE email = ?').get(email);
0 commit comments