File size: 911 Bytes
510332d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
37
import dotenv from 'dotenv';
dotenv.config();
import mongoose from 'mongoose';

const ADMIN_EMAIL = 'nerdyjinnyas@gmail.com';

const userSchema = new mongoose.Schema({
    email: String,
    isAdmin: Boolean,
    credits: Number,
    isBanned: Boolean
});

async function run() {
    await mongoose.connect(process.env.MONGO_URI);
    console.log('Connected to MongoDB');
    
    const User = mongoose.model('User', userSchema);
    
    const result = await User.findOneAndUpdate(
        { email: ADMIN_EMAIL },
        { $set: { isAdmin: true } },
        { new: true }
    );
    
    if (result) {
        console.log(`✅ Admin privileges granted to: ${result.email}`);
    } else {
        console.log(`ℹ️  User ${ADMIN_EMAIL} not found in DB yet. Admin will be set automatically on next login.`);
    }
    
    await mongoose.disconnect();
    console.log('Done.');
}

run().catch(console.error);