menu

SiteGenesis / Server-side JS / Source: app_storefront_controllers/cartridge/controllers/SourceCodeRedirect.js

'use strict';

/**
 * Controller that handles source code redirects.
 *
 * @module controllers/SourceCodeRedirect
 */

var app = require('~/cartridge/scripts/app');
var guard = require('~/cartridge/scripts/guard');

/**
 * Handles source code redirects. If the redirect succeeds, renders the redirect (util/redirect template).
 * If the redirect fails, calls the {@link module:controllers/Home~Show|Home controller Show function}.
 */
function start() {
    var sourceCodeRedirectURL = session.sourceCodeInfo.redirect;

    if (!sourceCodeRedirectURL) {
        app.getController('Home').Show();
        return;
    }

    app.getView({Location: sourceCodeRedirectURL.location}).render('util/redirect');
}

/*
 * Web exposed methods
 */
/** Handles source code redirects.
 * @see module:controllers/SourceCodeRedirect~start */
exports.Start = guard.ensure(['get'], start);

X Privacy Update: We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used. By continuing to use this site you are giving us your consent to do this. Privacy Policy.