forked from koushik369mondal/WanderLust
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheckUsers.js
More file actions
36 lines (28 loc) · 1.05 KB
/
checkUsers.js
File metadata and controls
36 lines (28 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const mongoose = require('mongoose');
const User = require('./models/user');
const MONGO_URL = "mongodb://127.0.0.1:27017/wanderlust";
const dbUrl = process.env.ATLAS_DB_URL || MONGO_URL;
async function checkUsers() {
try {
await mongoose.connect(dbUrl);
// Check all users
const users = await User.find({});
console.log('All users:', users.map(u => ({ username: u.username, isAdmin: u.isAdmin })));
// Create a simple admin with different password
await User.deleteMany({ username: { $in: ['admin', 'testadmin'] } });
const admin = new User({
username: 'testadmin',
email: 'test@admin.com',
isAdmin: true
});
await User.register(admin, '123456');
console.log('✅ Test admin created!');
console.log('Username: testadmin');
console.log('Password: 123456');
process.exit(0);
} catch (error) {
console.error('Error:', error);
process.exit(1);
}
}
checkUsers();