This repository was archived by the owner on Sep 16, 2026. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathUser.js
More file actions
155 lines (155 loc) · 4.05 KB
/
Copy pathUser.js
File metadata and controls
155 lines (155 loc) · 4.05 KB
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
145
146
147
148
149
150
151
152
153
154
155
'use strict'
module.exports = (sequelize, DataTypes) => {
const User = sequelize.define(
'User', {
id: {
type: DataTypes.INTEGER(10).UNSIGNED,
primaryKey: true,
allowNull: false,
autoIncrement: true,
comment: 'Unique ID'
},
activated: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false,
comment: 'Whether Account is Activated'
},
username: {
type: DataTypes.STRING(30),
allowNull: false,
unique: 'username',
comment: 'Unique Username'
},
password: {
type: DataTypes.STRING(100),
allowNull: false,
comment: 'Hash Encoded Password'
},
email: {
type: DataTypes.STRING(100),
allowNull: false,
unique: 'email',
comment: 'Unique Email Address'
},
first_name: {
type: DataTypes.STRING(50),
comment: 'Users First Name'
},
last_name: {
type: DataTypes.STRING(50),
comment: 'Users Last Name'
},
company_name: {
type: DataTypes.STRING(100),
comment: 'Company Name'
},
profile_name: {
type: DataTypes.STRING(100),
comment: ' Profile / Display Name of User'
},
profile_photo: {
type: DataTypes.STRING(255),
comment: 'Absolute URL of Profile Photo'
},
location: {
type: DataTypes.STRING(50),
comment: 'Users Provided Location'
},
profile_link_website: {
type: DataTypes.STRING(100),
comment: 'Profile Link Website'
},
profile_link_twitter: {
type: DataTypes.STRING(100),
comment: 'Profile Link Twitter'
},
profile_link_1: {
type: DataTypes.STRING(100),
comment: 'Misc Profile Link #1'
},
profile_link_2: {
type: DataTypes.STRING(100),
comment: 'Misc Profile Link #2'
},
profile_link_3: {
type: DataTypes.STRING(100),
comment: 'Misc Profile Link #3'
},
bio: {
type: DataTypes.STRING(255),
comment: 'Users Bio'
},
banned: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false,
comment: ' Whether the Account is Banned'
},
banned_reason: {
type: DataTypes.TEXT,
comment: 'Reason the Account was Banned'
},
new_password: {
type: DataTypes.STRING(100),
comment: 'Store New Password while Password Change is in Progress'
},
new_password_key: {
type: DataTypes.STRING(25),
unique: 'new_password_key',
comment: 'Confirmation Link for User to Confirm Password Change'
},
new_password_requested: {
type: DataTypes.DATE,
defaultValue: DataTypes.NOW,
comment: 'Date & Time Password Change was Requested'
},
new_email: {
type: DataTypes.STRING(100),
unique: 'new_email',
comment: 'Store New Email while Email Change is in Progress'
},
new_email_key: {
type: DataTypes.STRING(25),
unique: 'new_email_key',
comment: 'Confirmation Link for User to Confirm Email Change'
},
new_email_requested: {
type: DataTypes.DATE,
defaultValue: DataTypes.NOW,
comment: 'Date & Time Email Change was Requested'
}
}, {
timestamps: true,
paranoid: true,
freezeTableName: true,
singular: 'user',
plural: 'users',
tableName: 'users',
engine: 'InnoDB',
collate: 'utf8_unicode_ci',
charset: 'utf8mb4',
comment: 'User Model',
indexes: [{
name: 'idx_activated',
fields: ['activated']
},
{
name: 'idx_banned',
fields: ['banned']
}
]
}
)
User.associate = function(models) {
User.hasOne(models.UserFollow, {
foreignKey: 'follow_user_id',
target: 'id'
})
User.hasOne(models.UserInvite, {
foreignKey: 'new_user_id',
target: 'id'
})
}
return User
}