Merge pull request #180 from Permissionless-Software-Foundation/ct-unstable

fix(utils): Adding script to update users password or convert to admin
This commit is contained in:
Chris Troutner
2025-10-25 14:24:43 -07:00
committed by GitHub
2 changed files with 31 additions and 1 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
import mongoose from 'mongoose' import mongoose from 'mongoose'
import config from '../../config/index.js' import config from '../../config/index.js'
import User from '../../src/models/users.js' import User from '../../src/adapters/localdb/models/users.js'
async function getUsers () { async function getUsers () {
// Connect to the Mongo Database. // Connect to the Mongo Database.
+30
View File
@@ -0,0 +1,30 @@
import mongoose from 'mongoose'
import config from '../../config/index.js'
import User from '../../src/adapters/localdb/models/users.js'
async function getUsers () {
// Connect to the Mongo Database.
mongoose.Promise = global.Promise
mongoose.set('useCreateIndex', true) // Stop deprecation warning.
await mongoose.connect(
config.database,
{ useNewUrlParser: true, useUnifiedTopology: true }
)
// Find the user by email.
const user = await User.find({
email: 'test@test.com'
}, '-password')
// Update the users password
// user.password = 'newpassword'
// Change the user to an admin
// user.type = 'admin'
// Save the changes to the database.
await user.save()
mongoose.connection.close()
}
getUsers()