Move to bcryptjs from bcrypt

This commit is contained in:
oitsjustjose 2021-04-25 12:30:32 -07:00
commit 051da89b4d
3 changed files with 68 additions and 471 deletions

View file

@ -1,7 +1,16 @@
import bcrypt from 'bcrypt'
import bcrypt from 'bcryptjs'
import { Document, model, Schema, Types } from 'mongoose'
const UserSchema = new Schema({
export type UserModel = Document & {
username: string,
password: string,
configs: string[],
generateHash: (password: string) => string,
validPassword: (password: string) => string,
changePassword: (password: string, newPassword: string) => void
}
const UserSchema: Schema<UserModel> = new Schema({
username: String,
password: String,
configs: [{
@ -23,13 +32,4 @@ UserSchema.methods.changePassword = function (password: string, newPassword: str
}
}
export type UserModel = Document & {
username: string,
password: string,
configs: string[],
generateHash: (password: string) => string,
validPassword: (password: string) => string,
changePassword: (password: string, newPassword: string) => void
}
export default model<UserModel>('users', UserSchema, 'users')