| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- const validator = require('validator')
- const mongoose = require('mongoose')
- const bcrypt = require('bcryptjs')
- const jwt = require('jsonwebtoken')
- const ejwt = require('express-jwt')
-
- const userSchema = new mongoose.Schema({
- name: {
- type: String
- },
- email: {
- type: String,
- required: true
- },
- password: {
- type: String,
- required: true
- },
- tokens: [{
- token: {
- type: String,
- required: true
- }
- }]
- })
-
- // userSchema.pre('save', async function(next) {
- // const user = this
- // console.log('pre hash: ' + user.password)
-
- // user.password = await bcrypt.hash(user.password, 8)
-
- // console.log('posle hash: ' + user.password)
-
- // console.log('Middleware before password hash')
- // next()
- // })
-
- const User = mongoose.model('User', userSchema)
-
- module.exports = User
|