Schema refactoring
This commit is contained in:
@ -2,21 +2,35 @@ var mongoose = require('mongoose'),
|
|||||||
bcrypt = require('bcrypt');
|
bcrypt = require('bcrypt');
|
||||||
|
|
||||||
var userSchema = new mongoose.Schema({
|
var userSchema = new mongoose.Schema({
|
||||||
|
|
||||||
|
// Local authentication
|
||||||
username: { type: String, index: true, unique: true },
|
username: { type: String, index: true, unique: true },
|
||||||
email: String,
|
|
||||||
name: String,
|
|
||||||
password: String,
|
password: String,
|
||||||
|
|
||||||
|
// OAuth 2.0 authentication
|
||||||
|
provider: String,
|
||||||
|
facebook: String,
|
||||||
|
twitter: String,
|
||||||
|
google: String,
|
||||||
|
github: String,
|
||||||
|
|
||||||
|
// Optional profile information
|
||||||
|
profile: {
|
||||||
|
name: String,
|
||||||
|
email: String,
|
||||||
|
location: String,
|
||||||
|
website: String,
|
||||||
|
picture: String
|
||||||
|
},
|
||||||
|
|
||||||
|
// API access tokens
|
||||||
tokens: {
|
tokens: {
|
||||||
google: String,
|
google: String,
|
||||||
facebook: String,
|
facebook: String,
|
||||||
foursquare: String,
|
foursquare: String,
|
||||||
twitter: String,
|
twitter: String,
|
||||||
github: String
|
github: String
|
||||||
},
|
}
|
||||||
provider: String,
|
|
||||||
facebook: String,
|
|
||||||
google: String,
|
|
||||||
isAdmin: Boolean
|
|
||||||
});
|
});
|
||||||
|
|
||||||
userSchema.path('password').validate(function(password) {
|
userSchema.path('password').validate(function(password) {
|
||||||
|
Reference in New Issue
Block a user