|
|
@@ -11,7 +11,7 @@ module.exports = function(crowi) {
|
|
|
, STATUS_SUSPENDED = 3
|
|
|
, STATUS_DELETED = 4
|
|
|
, STATUS_INVITED = 5
|
|
|
- , USER_PUBLIC_FIELDS = '_id fbId image googleId name username email status createdAt' // TODO: どこか別の場所へ...
|
|
|
+ , USER_PUBLIC_FIELDS = '_id image googleId name username email status createdAt' // TODO: どこか別の場所へ...
|
|
|
|
|
|
, PAGE_ITEMS = 20
|
|
|
|
|
|
@@ -21,7 +21,6 @@ module.exports = function(crowi) {
|
|
|
|
|
|
userSchema = new mongoose.Schema({
|
|
|
userId: String,
|
|
|
- fbId: String, // userId
|
|
|
image: String,
|
|
|
googleId: String,
|
|
|
name: { type: String },
|
|
|
@@ -137,17 +136,6 @@ module.exports = function(crowi) {
|
|
|
return this.updateImage(null, callback);
|
|
|
};
|
|
|
|
|
|
- userSchema.methods.updateFacebookId = function(fbId, callback) {
|
|
|
- this.fbId = this.userId = fbId;
|
|
|
- this.save(function(err, userData) {
|
|
|
- return callback(err, userData);
|
|
|
- });
|
|
|
- };
|
|
|
-
|
|
|
- userSchema.methods.deleteFacebookId = function(callback) {
|
|
|
- return this.updateFacebookId(null, callback);
|
|
|
- };
|
|
|
-
|
|
|
userSchema.methods.updateGoogleId = function(googleId, callback) {
|
|
|
this.googleId = googleId;
|
|
|
this.save(function(err, userData) {
|
|
|
@@ -218,16 +206,14 @@ module.exports = function(crowi) {
|
|
|
this.password = '';
|
|
|
this.email = 'deleted@deleted';
|
|
|
this.googleId = null;
|
|
|
- this.fbId = null;
|
|
|
this.image = null;
|
|
|
this.save(function(err, userData) {
|
|
|
return callback(err, userData);
|
|
|
});
|
|
|
};
|
|
|
|
|
|
- userSchema.methods.updateGoogleIdAndFacebookId = function(googleId, facebookId, callback) {
|
|
|
+ userSchema.methods.updateGoogleId = function(googleId, callback) {
|
|
|
this.googleId = googleId;
|
|
|
- this.fbId = this.userId = facebookId;
|
|
|
this.save(function(err, userData) {
|
|
|
return callback(err, userData);
|
|
|
});
|
|
|
@@ -367,12 +353,6 @@ module.exports = function(crowi) {
|
|
|
});
|
|
|
};
|
|
|
|
|
|
- userSchema.statics.findUserByFacebookId = function(fbId, callback) {
|
|
|
- this.findOne({userId: fbId}, function (err, userData) {
|
|
|
- callback(err, userData);
|
|
|
- });
|
|
|
- };
|
|
|
-
|
|
|
userSchema.statics.findUserByGoogleId = function(googleId, callback) {
|
|
|
this.findOne({googleId: googleId}, function (err, userData) {
|
|
|
callback(err, userData);
|
|
|
@@ -571,27 +551,6 @@ module.exports = function(crowi) {
|
|
|
});
|
|
|
};
|
|
|
|
|
|
- userSchema.statics.createUserByFacebook = function(fbUserInfo, callback) {
|
|
|
- var User = this
|
|
|
- , newUser = new User();
|
|
|
-
|
|
|
- newUser.userId = fbUserInfo.id;
|
|
|
- newUser.image = '//graph.facebook.com/' + fbUserInfo.id + '/picture?size=square';
|
|
|
- newUser.name = fbUserInfo.name || '';
|
|
|
- newUser.username = fbUserInfo.username || '';
|
|
|
- newUser.email = fbUserInfo.email || '';
|
|
|
- newUser.createdAt = Date.now();
|
|
|
- newUser.status = decideUserStatusOnRegistration();
|
|
|
-
|
|
|
- newUser.save(function(err, userData) {
|
|
|
- if (userData.status == STATUS_ACTIVE) {
|
|
|
- userEvent.emit('activated', userData);
|
|
|
- }
|
|
|
- return callback(err, userData);
|
|
|
- });
|
|
|
- };
|
|
|
-
|
|
|
-
|
|
|
userSchema.statics.createUserPictureFilePath = function(user, name) {
|
|
|
var ext = '.' + name.match(/(.*)(?:\.([^.]+$))/)[2];
|
|
|
|