fix find instance or currentInstance
This commit is contained in:
		@@ -6,10 +6,17 @@ var defaultProfileImage =
 | 
				
			|||||||
module.exports = function(UserIdent) {
 | 
					module.exports = function(UserIdent) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 UserIdent.observe('before save', function(ctx, next) {
 | 
					 UserIdent.observe('before save', function(ctx, next) {
 | 
				
			||||||
  var userIdent = ctx.currentInstance;
 | 
					  var userIdent = ctx.currentInstance || ctx.instance;
 | 
				
			||||||
  // treat userIdent as immutable
 | 
					  if (userIdent) {
 | 
				
			||||||
 | 
					    debug('no user identity instance found');
 | 
				
			||||||
 | 
					    return next();
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
  userIdent.user(function(err, user) {
 | 
					  userIdent.user(function(err, user) {
 | 
				
			||||||
    if (err) { return next(err); }
 | 
					    if (err) { return next(err); }
 | 
				
			||||||
 | 
					    if (!user) {
 | 
				
			||||||
 | 
					      debug('no user attached to identity!');
 | 
				
			||||||
 | 
					      return next();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    debug('got user', user.username);
 | 
					    debug('got user', user.username);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    var picture = userIdent.profile && userIdent.profile[0] ?
 | 
					    var picture = userIdent.profile && userIdent.profile[0] ?
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user