lib/cycle.js
function(req, res, user, error) {
      waterlock.logger.debug('user register failure');

      if (user) {
        var address = this._addressFromRequest(req);

        var attempt = {
          user: user.id,
          successful: false
        };

        _.merge(attempt, address);

        waterlock.Attempt.create(attempt).exec(function(err) {
          if (err) {
            waterlock.logger.debug(err);
          }
        });
      }

      if (req.session.authenticated) {
        req.session.authenticated = false;
      }

      delete(req.session.user);

      // now respond or redirect
      var postResponse = this._resolvePostAction(waterlock.config.postActions.register.failure,
        error);

      if (typeof postResponse === 'string' && this._isURI(postResponse)) {
        res.redirect(postResponse);
      } else {
        res.forbidden(postResponse);
      }
    }
function(req, res, user, error) {
      waterlock.logger.debug('user register failure');

      if (user) {
        var address = this._addressFromRequest(req);

        var attempt = {
          user: user.id,
          successful: false
        };

        _.merge(attempt, address);

        waterlock.Attempt.create(attempt).exec(function(err) {
          if (err) {
            waterlock.logger.debug(err);
          }
        });
      }

      if (req.session.authenticated) {
        req.session.authenticated = false;
      }

      delete(req.session.user);

      // now respond or redirect
      var postResponse = this._resolvePostAction(waterlock.config.postActions.register.failure,
        error);

      if (typeof postResponse === 'string' && this._isURI(postResponse)) {
        res.redirect(postResponse);
      } else {
        res.forbidden(postResponse);
      }
    }
function ( req , res , user , error ) { waterlock . logger . debug ( 'user register failure' ) ; if ( user ) { var address = this . _addressFromRequest ( req ) ; var attempt = { user : user . id , successful : false } ; _ . merge ( attempt , address ) ; waterlock . Attempt . create ( attempt ) . exec ( function ( err ) { if ( err ) { waterlock . logger . debug ( err ) ; } } ) ; } if ( req . session . authenticated ) { req . session . authenticated = false ; } delete ( req . session . user ) ; // now respond or redirect var postResponse = this . _resolvePostAction ( waterlock . config . postActions . register . failure , error ) ; if ( typeof postResponse === 'string' && this . _isURI ( postResponse ) ) { res . redirect ( postResponse ) ; } else { res . forbidden ( postResponse ) ; } }
handles registration failures

@param  {Object} req  express request object
@param  {Object} res  expresss response object
@param  {Object} user the user instance
@param  {Object|String} error the error that caused the failure
@api public
handles registration failures