File size: 744 Bytes
1dc8372
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const Datastore = require('nedb-promises');
const path = require('path');
const bcrypt = require('bcryptjs');

async function fixUser() {
  const users = Datastore.create({ filename: path.join(__dirname, 'data', 'users.db'), autoload: true });
  
  const email = 'johanvoncd7@gmail.com';
  const newPassword = 'admin123';
  const salt = await bcrypt.genSalt(10);
  const hashedPassword = await bcrypt.hash(newPassword, salt);

  const user = await users.findOne({ email });
  if (user) {
    await users.update({ _id: user._id }, { $set: { isVerified: true, password: hashedPassword } });
    console.log(`User ${email} verified and password reset to: ${newPassword}`);
  } else {
    console.log(`User ${email} not found.`);
  }
}

fixUser();