Skip to content

Commit

Permalink
fix find instance or currentInstance
Browse files Browse the repository at this point in the history
  • Loading branch information
Berkeley Martinez authored and Berkeley Martinez committed Jun 11, 2015
1 parent fe5cbec commit 0d32cf7
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions common/models/User-Identity.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,17 @@ var defaultProfileImage =
module.exports = function(UserIdent) {

UserIdent.observe('before save', function(ctx, next) {
var userIdent = ctx.currentInstance;
// treat userIdent as immutable
var userIdent = ctx.currentInstance || ctx.instance;
if (userIdent) {
debug('no user identity instance found');
return next();
}
userIdent.user(function(err, user) {
if (err) { return next(err); }
if (!user) {
debug('no user attached to identity!');
return next();
}
debug('got user', user.username);

var picture = userIdent.profile && userIdent.profile[0] ?
Expand Down

0 comments on commit 0d32cf7

Please sign in to comment.