Skip to content

Commit 3bcd1e3

Browse files
rainerstudiosclaude
andcommitted
Remove legacy authentication code - use Better Auth only
Breaking changes: - Removed all Passport.js and dual authentication code - Removed lib/dual-auth.js, lib/better-auth-verify.js, lib/steam-auth.js.backup - Created simplified lib/auth.js with Better Auth only - Updated all endpoints to use requireAuth instead of dualAuth - No more JWT token support - only Better Auth session tokens Benefits: - Cleaner, simpler codebase - Only one authentication method - All users must use Better Auth (Next.js frontend) - Automatic user sync to legacy users table still works Backend now ONLY accepts Better Auth session tokens from Next.js frontend. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 3b3f188 commit 3bcd1e3

5 files changed

Lines changed: 212 additions & 794 deletions

File tree

index.js

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -78,19 +78,14 @@ app.use(function (error, req, res, next) {
7878
// =====================================================================
7979
// STEAM AUTHENTICATION SETUP
8080
// =====================================================================
81-
// REMOVED: Passport.js authentication - migrating to Better Auth
82-
// const session = require('express-session');
83-
// const passport = require('passport');
84-
// const steamAuth = require('./lib/steam-auth');
85-
86-
// Use dual authentication middleware (supports Better Auth tokens)
87-
const dualAuthModule = require('./lib/dual-auth');
88-
const { dualAuth, optionalAuth } = dualAuthModule;
81+
// Better Auth authentication (from Next.js frontend)
82+
const auth = require('./lib/auth');
83+
const { requireAuth, optionalAuth } = auth;
8984
const steamInventory = require('./lib/steam-inventory');
9085

91-
// Initialize dual-auth with postgres connection
92-
dualAuthModule.initialize(postgres);
93-
winston.info('Better Auth token verification configured');
86+
// Initialize auth with postgres connection
87+
auth.initialize(postgres);
88+
winston.info('Better Auth authentication configured');
9489

9590

9691

@@ -3494,8 +3489,6 @@ winston.info('Portfolio snapshots and advanced features loaded');
34943489
// AUTHENTICATION & API KEY MANAGEMENT ENDPOINTS
34953490
// =====================================================================
34963491

3497-
const auth = require('./lib/auth');
3498-
34993492
// Create API key
35003493
app.post('/api/auth/create-key', async (req, res) => {
35013494
try {
@@ -4030,7 +4023,7 @@ winston.info('Using Better Auth for authentication (configured in Next.js fronte
40304023
// =====================================================================
40314024

40324025
// Get user's CS2 inventory
4033-
app.get('/api/steam/inventory/:steamId', dualAuth, async (req, res) => {
4026+
app.get('/api/steam/inventory/:steamId', requireAuth, async (req, res) => {
40344027
try {
40354028
const { steamId } = req.params;
40364029

@@ -4056,7 +4049,7 @@ app.get('/api/steam/inventory/:steamId', dualAuth, async (req, res) => {
40564049
});
40574050

40584051
// Get inventory value estimate
4059-
app.get('/api/steam/inventory/:steamId/value', dualAuth, async (req, res) => {
4052+
app.get('/api/steam/inventory/:steamId/value', requireAuth, async (req, res) => {
40604053
try {
40614054
const { steamId } = req.params;
40624055

@@ -4082,7 +4075,7 @@ app.get('/api/steam/inventory/:steamId/value', dualAuth, async (req, res) => {
40824075
});
40834076

40844077
// Sync inventory to portfolio
4085-
app.post('/api/steam/inventory/sync', dualAuth, async (req, res) => {
4078+
app.post('/api/steam/inventory/sync', requireAuth, async (req, res) => {
40864079
try {
40874080
const steamId = req.user.steam_id;
40884081
const { selected_items = [] } = req.body;

0 commit comments

Comments
 (0)