lib/engine.js
function(auth, cb){
      var self = this;

      // create the user
      if(!auth.user){
        waterlock.User.create({auth:auth.id}).exec(function(err, user){
          if(err){
            waterlock.logger.debug(err);
            return cb(err);
          }

          // update the auth object
          waterlock.Auth.update(auth.id, {user:user.id}).exec(function(err, auth){
            if(err){
              waterlock.logger.debug(err);
              return cb(err);
            }

            user.auth = auth.shift();
            cb(err, user);
          });
        });
      }else{
        // just fire off update to user object so we can get the
        // backwards association going.
        if(!auth.user.auth){
          waterlock.User.update(auth.user.id, {auth:auth.id}).exec(function(){});
        }

        cb(null, self._invertAuth(auth));
      }
    }
function(auth, cb){
      var self = this;

      // create the user
      if(!auth.user){
        waterlock.User.create({auth:auth.id}).exec(function(err, user){
          if(err){
            waterlock.logger.debug(err);
            return cb(err);
          }

          // update the auth object
          waterlock.Auth.update(auth.id, {user:user.id}).exec(function(err, auth){
            if(err){
              waterlock.logger.debug(err);
              return cb(err);
            }

            user.auth = auth.shift();
            cb(err, user);
          });
        });
      }else{
        // just fire off update to user object so we can get the
        // backwards association going.
        if(!auth.user.auth){
          waterlock.User.update(auth.user.id, {auth:auth.id}).exec(function(){});
        }

        cb(null, self._invertAuth(auth));
      }
    }
function ( auth , cb ) { var self = this ; // create the user if ( ! auth . user ) { waterlock . User . create ( { auth : auth . id } ) . exec ( function ( err , user ) { if ( err ) { waterlock . logger . debug ( err ) ; return cb ( err ) ; } // update the auth object waterlock . Auth . update ( auth . id , { user : user . id } ) . exec ( function ( err , auth ) { if ( err ) { waterlock . logger . debug ( err ) ; return cb ( err ) ; } user . auth = auth . shift ( ) ; cb ( err , user ) ; } ) ; } ) ; } else { // just fire off update to user object so we can get the // backwards association going. if ( ! auth . user . auth ) { waterlock . User . update ( auth . user . id , { auth : auth . id } ) . exec ( function ( ) { } ) ; } cb ( null , self . _invertAuth ( auth ) ) ; } }
This will create a user and auth object if one is not found

@param  {Object}   criteria   should be id to find the auth by
@param  {Object}   attributes auth attributes
@param  {Function} cb         function to be called when the auth has been
found or an error has occurred
@api private
This will create a user and auth object if one is not found