diff --git a/check-corrupted-passwords.mjs b/check-corrupted-passwords.mjs deleted file mode 100644 index a75d7e19..00000000 --- a/check-corrupted-passwords.mjs +++ /dev/null @@ -1,58 +0,0 @@ -import { MongoClient } from "mongodb"; -import dotenv from "dotenv"; - -// Load environment variables -dotenv.config(); - -// Test script to check for users that might have corrupted passwords -async function checkCorruptedPasswords() { - const uri = - process.env.MONGODB_URI || "mongodb://localhost:27017/skillswaphub"; - const client = new MongoClient(uri); - - try { - await client.connect(); - const db = client.db(); - - console.log( - "šŸ” Checking for users with potentially corrupted passwords..." - ); - - // Find users with very long passwords (likely double-hashed) - const users = await db - .collection("users") - .find({ password: { $exists: true } }) - .toArray(); - - console.log(`šŸ“Š Found ${users.length} users with passwords`); - - for (const user of users) { - const passwordLength = user.password ? user.password.length : 0; - const isProperBcrypt = user.password && user.password.startsWith("$2"); - - console.log(`šŸ‘¤ ${user.firstName} ${user.lastName} (${user.email})`); - console.log(` Password length: ${passwordLength}`); - console.log(` Proper bcrypt format: ${isProperBcrypt}`); - console.log(` Created: ${user.createdAt}`); - console.log(` Updated: ${user.updatedAt}`); - - // Check if password is suspiciously long (double-hashed) - if (passwordLength > 80) { - console.log( - ` āš ļø SUSPICIOUS: Password is very long (${passwordLength} chars) - might be double-hashed` - ); - } - - console.log(""); - } - - console.log("\nāœ… Check completed"); - } catch (error) { - console.error("āŒ Error checking passwords:", error); - } finally { - await client.close(); - } -} - -// Run the check -checkCorruptedPasswords().catch(console.error); diff --git a/create-test-user.js b/create-test-user.js deleted file mode 100644 index e69de29b..00000000 diff --git a/scripts/MIGRATION_GUIDE.md b/scripts/MIGRATION_GUIDE.md deleted file mode 100644 index e69de29b..00000000 diff --git a/test-admin-auth-success-stories.js b/test-admin-auth-success-stories.js deleted file mode 100644 index fe829990..00000000 --- a/test-admin-auth-success-stories.js +++ /dev/null @@ -1,57 +0,0 @@ -// Test admin success stories API with authentication -const testAdminSuccessStoriesWithAuth = async () => { - try { - console.log("šŸ” Testing admin success stories API with authentication...\n"); - - // First login to get the token - const loginResponse = await fetch("http://localhost:3000/api/admin/login", { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ - username: "superadmin", - password: "SuperAdmin123!", - }), - }); - - if (!loginResponse.ok) { - console.error("āŒ Login failed:", await loginResponse.text()); - return; - } - - // Get the cookie from the response - const setCookieHeader = loginResponse.headers.get("set-cookie"); - console.log("āœ… Login successful"); - - // Now test the success stories API - const successStoriesResponse = await fetch( - "http://localhost:3000/api/admin/success-stories?page=1&limit=10&search=&status=all", - { - method: "GET", - headers: { - Cookie: setCookieHeader || "", - }, - } - ); - - console.log("Response status:", successStoriesResponse.status); - - const successStoriesData = await successStoriesResponse.json(); - console.log("Response data:", JSON.stringify(successStoriesData, null, 2)); - - if (successStoriesResponse.ok && successStoriesData.success) { - console.log("āœ… Admin success stories API working correctly"); - console.log(`šŸ“Š Found ${successStoriesData.data.successStories.length} success stories`); - console.log(`šŸ“„ Total pages: ${successStoriesData.data.pagination.totalPages}`); - } else { - console.error("āŒ Admin success stories API failed"); - } - - } catch (error) { - console.error("āŒ Error testing admin API:", error.message); - } -}; - -// Wait a bit for the server to be ready -setTimeout(testAdminSuccessStoriesWithAuth, 1000); diff --git a/test-admin-success-stories.js b/test-admin-success-stories.js deleted file mode 100644 index 76632341..00000000 --- a/test-admin-success-stories.js +++ /dev/null @@ -1,26 +0,0 @@ -// Test script to check admin success stories API -async function testAdminSuccessStoriesAPI() { - try { - console.log('Testing admin success stories API...'); - - // First, let's test without authentication to see the error - const response = await fetch('http://localhost:3000/api/admin/success-stories'); - const data = await response.json(); - - console.log('Response status:', response.status); - console.log('Response data:', JSON.stringify(data, null, 2)); - - if (response.status === 401) { - console.log('āœ… API correctly requires authentication'); - } else if (response.status === 500) { - console.error('āŒ API returning 500 error - schema issue likely'); - } else { - console.log('āœ… API working correctly'); - } - } catch (error) { - console.error('āŒ Error testing API:', error.message); - } -} - -// Wait a bit for the server to be ready -setTimeout(testAdminSuccessStoriesAPI, 1000); diff --git a/test-login-credentials.mjs b/test-login-credentials.mjs deleted file mode 100644 index 71d8cbcb..00000000 --- a/test-login-credentials.mjs +++ /dev/null @@ -1,68 +0,0 @@ -import { MongoClient } from "mongodb"; -import dotenv from "dotenv"; -import bcrypt from "bcryptjs"; - -// Load environment variables -dotenv.config(); - -// Test script to verify login credentials for unsuspended users -async function testLoginCredentials() { - const uri = - process.env.MONGODB_URI || "mongodb://localhost:27017/skillswaphub"; - const client = new MongoClient(uri); - - try { - await client.connect(); - const db = client.db(); - - console.log("šŸ” Testing login credentials for unsuspended users..."); - - // Get the recently unsuspended user - const user = await db - .collection("users") - .findOne({ email: "suspended@test.com" }); - - if (user) { - console.log( - `šŸ‘¤ Found user: ${user.firstName} ${user.lastName} (${user.email})` - ); - console.log(`šŸ”‘ Has password field: ${!!user.password}`); - console.log( - `šŸ“ Password length: ${user.password ? user.password.length : 0}` - ); - console.log( - `šŸ” Password starts with $2: ${user.password ? user.password.startsWith("$2") : false}` - ); - console.log(`šŸ“… Created: ${user.createdAt}`); - console.log(`šŸ”„ Updated: ${user.updatedAt}`); - console.log(`šŸ‘¤ Google User: ${user.isGoogleUser}`); - console.log(`āœ… Profile Completed: ${user.profileCompleted}`); - - // Test password comparison (if password exists) - if (user.password) { - const testPassword = "password123"; // Common test password - const testPassword2 = "test123"; // Another common test password - - try { - const isValid1 = await bcrypt.compare(testPassword, user.password); - const isValid2 = await bcrypt.compare(testPassword2, user.password); - console.log(`šŸ”“ Password 'password123' is valid: ${isValid1}`); - console.log(`šŸ”“ Password 'test123' is valid: ${isValid2}`); - } catch (error) { - console.log(`āŒ Error comparing passwords: ${error.message}`); - } - } - } else { - console.log("āŒ User not found"); - } - - console.log("\nāœ… Test completed"); - } catch (error) { - console.error("āŒ Error testing login credentials:", error); - } finally { - await client.close(); - } -} - -// Run the test -testLoginCredentials().catch(console.error); diff --git a/test-success-stories.js b/test-success-stories.js deleted file mode 100644 index 66faa233..00000000 --- a/test-success-stories.js +++ /dev/null @@ -1,23 +0,0 @@ -// Test script to check success stories API - -async function testSuccessStoriesAPI() { - try { - console.log('Testing success stories API...'); - const response = await fetch('http://localhost:3000/api/success-stories?limit=6'); - const data = await response.json(); - - console.log('Response status:', response.status); - console.log('Response data:', JSON.stringify(data, null, 2)); - - if (response.status === 500) { - console.error('āŒ API still returning 500 error'); - } else { - console.log('āœ… API working correctly'); - } - } catch (error) { - console.error('āŒ Error testing API:', error.message); - } -} - -// Wait a bit for the server to be ready -setTimeout(testSuccessStoriesAPI, 2000);