ADD: email, emailUnique, passwordChangedAt, passwordResetToken, and passwordResetExpires attributes
This commit is contained in:
@@ -1,21 +1,37 @@
|
|||||||
const mongoose = require('mongoose')
|
const mongoose = require('mongoose')
|
||||||
const ObjectID = mongoose.Schema.Types.ObjectId
|
const ObjectID = mongoose.Schema.Types.ObjectId
|
||||||
|
const validator = require('validator')
|
||||||
|
|
||||||
const userSchema = new mongoose.Schema(
|
const userSchema = new mongoose.Schema(
|
||||||
{
|
{
|
||||||
name: String,
|
name: String,
|
||||||
|
email: {
|
||||||
|
type: String,
|
||||||
|
lowercase: true,
|
||||||
|
required: true,
|
||||||
|
validate: [validator.isEmail, 'Please provide a valid email'],
|
||||||
|
},
|
||||||
|
emailUnique: {
|
||||||
|
type: String,
|
||||||
|
default: function () {
|
||||||
|
return this.email || `no-email-${this._id}`
|
||||||
|
},
|
||||||
|
},
|
||||||
password: {
|
password: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
trim: true,
|
trim: true,
|
||||||
},
|
},
|
||||||
|
passwordChangedAt: Date,
|
||||||
|
passwordResetToken: String,
|
||||||
|
passwordResetExpires: Date,
|
||||||
isActive: {
|
isActive: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
role: {
|
role: {
|
||||||
type: ObjectID,
|
type: ObjectID,
|
||||||
ref: 'Role'
|
ref: 'Role',
|
||||||
},
|
},
|
||||||
isAdmin: {
|
isAdmin: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
|||||||
Reference in New Issue
Block a user