Use next-basics package.

This commit is contained in:
Mike Cao 2022-08-28 20:20:54 -07:00
parent 1a6af8fc41
commit f4e0da481e
62 changed files with 255 additions and 373 deletions

View file

@ -1,11 +1,11 @@
/* eslint-disable no-console */
require('dotenv').config();
const bcrypt = require('bcryptjs');
const { hashPassword } = require('next-basics');
const chalk = require('chalk');
const prompts = require('prompts');
const { PrismaClient } = require('@prisma/client');
const prisma = new PrismaClient();
const SALT_ROUNDS = 10;
const runQuery = async query => {
return query.catch(e => {
@ -24,10 +24,6 @@ const updateAccountByUsername = (username, data) => {
);
};
const hashPassword = password => {
return bcrypt.hashSync(password, SALT_ROUNDS);
};
const changePassword = async (username, newPassword) => {
const password = hashPassword(newPassword);
return updateAccountByUsername(username, { password });