var AuthLoader = require('../authorizer/index').AuthLoader,
    createAuthInterface = require('../authorizer/auth-interface'),

    util = require('../authorizer/util');

module.exports = [
    // Post authorization.
    function (context, run, done) {
        // if no response is provided, there's nothing to do, and probably means that the request errored out
        // let the actual request command handle whatever needs to be done.
        if (!context.response) { return done(); }

        // bail out if there is no auth
        if (!(context.auth && context.auth.type)) { return done(); }

        // bail out if interactive mode is disabled
        if (!util.isInteractiveForAuth(run.options, context.auth.type)) { return done(); }

        var auth = context.auth,
            authHandler = AuthLoader.getHandler(auth.type),
            authInterface = createAuthInterface(auth);

        // invoke `post` on the Auth
        authHandler.post(authInterface, context.response, function (err, success) {
            // sync auth state back to item request
            _.set(context, 'item.request.auth', auth);

            // there was an error in auth post hook
            if (err) { return done(err); }

            // auth was verified
            if (success) { return done(); }

            // request a replay of request
            done(null, {replay: true});
        });
    }
];

var _ = require('lodash'),

    AuthLoader = require('../authorizer/index').AuthLoader,
    createAuthInterface = require('../authorizer/auth-interface'),

    util = require('../authorizer/util');

module.exports = [
    // Post authorization.
    function (context, run, done) {
        // if no response is provided, there's nothing to do, and probably means that the request errored out
        // let the actual request command handle whatever needs to be done.
        if (!context.response) { return done(); }

        // bail out if there is no auth
        if (!(context.auth && context.auth.type)) { return done(); }

        // bail out if interactive mode is disabled
        if (!util.isInteractiveForAuth(run.options, context.auth.type)) { return done(); }

        var auth = context.auth,
            authHandler = AuthLoader.getHandler(auth.type),
            authInterface = createAuthInterface(auth);

        // invoke `post` on the Auth
        authHandler.post(authInterface, context.response, function (err, success) {
            // sync auth state back to item request
            _.set(context, 'item.request.auth', auth);

            // there was an error in auth post hook
            if (err) { return done(err); }

            // auth was verified
            if (success) { return done(); }

            // request a replay of request
            done(null, {replay: true});
        });
    }
];

Fix missing import in merge conflict resolution
Fix missing import in merge conflict resolution
