-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUser.js
144 lines (140 loc) · 2.59 KB
/
User.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
const mongoose = require('mongoose'),
Schema = mongoose.Schema,
bcrypt = require('bcryptjs');
const UserSchema = new Schema(
{
// ** ACCOUNT
username: {
type: String,
required: true,
lowercase: true,
index: { unique: true },
},
password: {
type: String,
required: true,
},
locked: {
type: Boolean,
default: false,
required: true,
},
// confirm reset pass
resetPasswordHash: {
type: String,
},
resetPasswordHashIssueDate: {
type: Date,
},
resetPasswordHashExpires: {
type: Date,
},
tryPasswordAttempts: {
type: Number,
default: 0,
required: true,
},
lastTimeUpdatedPassword: {
type: Date,
},
// ** PROFILE
email: {
type: String,
default: '',
},
firstName: {
type: String,
default: '',
},
lastName: {
type: String,
default: '',
},
phoneNumber: {
type: String,
default: '',
},
passport: {
type: String,
default: '',
},
address: {
type: String,
default: '',
},
city: {
type: String,
default: '',
},
state: {
type: String,
default: '',
},
zip: {
type: String,
default: '',
},
country: {
type: String,
default: 'United States',
},
isEmployed: {
type: Boolean,
default: true,
},
occupation: {
type: String,
default: '',
},
employer: {
type: String,
default: '',
},
// ** STATUS
isCompliant: {
// with FEC standards for higher donation limit
type: Boolean,
default: false,
},
understands: {
// "understands" eligibility requirements
type: Boolean,
default: false,
},
// ** stripe
payment: {
customer_id: {
type: String,
},
payment_method: {
type: String,
},
type: Object,
},
// user preferences
settings: {
emailReceipts: {
type: Boolean,
default: true,
},
autoTweet: {
type: Boolean,
default: false,
},
showToolTips: {
type: Boolean,
default: true,
},
type: Object,
},
// ** meta
createdAt: { type: Date, default: Date.now },
updatedAt: { type: Date, default: Date.now },
},
{ timestamps: true }
);
UserSchema.methods.comparePassword = function (password) {
return bcrypt.compareSync(password, this.password);
};
const User = mongoose.model('User', UserSchema);
module.exports = User;