Download makeAdmin.js from ismizo/bet: direct link, hf CLI and curl.
- Browser
- Download file 694 Bytes
-
https://huggingface.co/spaces/ismizo/bet/resolve/main/makeAdmin.js
- Command line
-
hf download hf://spaces/ismizo/bet/makeAdmin.js
-
curl -L -o makeAdmin.js https://huggingface.co/spaces/ismizo/bet/resolve/main/makeAdmin.js
694 Bytes
| import dotenv from 'dotenv'; | |
| dotenv.config(); | |
| import { connectDB } from './src/db.js'; | |
| import User from './src/models/User.js'; | |
| async function run() { | |
| const email = process.argv[2]; | |
| if (!email) { | |
| console.error("Please provide an email. Usage: node makeAdmin.js <email>"); | |
| process.exit(1); | |
| } | |
| await connectDB(); | |
| const user = await User.findOne({ email }); | |
| if (!user) { | |
| console.error(`User with email ${email} not found.`); | |
| process.exit(1); | |
| } | |
| user.isAdmin = true; | |
| await user.save(); | |
| console.log(`Successfully made ${email} an Admin! They can now see the "Admin Panel" upon logging in.`); | |
| process.exit(0); | |
| } | |
| run(); | |