-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathUserModel.js
More file actions
86 lines (85 loc) · 2.45 KB
/
UserModel.js
File metadata and controls
86 lines (85 loc) · 2.45 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
module.exports = function(sequelize, DataTypes) {
return sequelize.define("User", {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
username: {
type: DataTypes.STRING,
allowNull: false,
unique: true
},
email: {
type: DataTypes.STRING,
allowNull: false,
unique: true,
validate: {
isEmail: true
}
},
password: {
type: DataTypes.STRING,
allowNull: false
},
firstname: {
type: DataTypes.STRING,
allowNull: true
// validate: {
// isAlphanumeric: true
// }
},
lastname: {
type: DataTypes.STRING,
allowNull: true
// validate: {
// isAlphanumeric: true
// }
},
phone : {
type:DataTypes.STRING,
allowNull: true
},
confirmed : {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false
},
active : {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: true
},
hasAdminRight : {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false
},
accessedAt : {
type: DataTypes.DATE,
allowNull: true
},
AccountId : {
type: DataTypes.INTEGER
},
EmailTemplateId : {
type: DataTypes.INTEGER
}
},
{
paranoid: true,
getterMethods: {
fullName: function(){
return [ this.getDataValue('firstname'), this.getDataValue('lastname')].join(' ');
}
},
instanceMethods: {
toJSON: function () {
var values = this.values;
values.fullName = this.fullName;
delete values.password;
return values;
}
}
});
};