/**
 * forbidden.js
 *
 * A custom response that content-negotiates the current request to either:
 *  * Log out the current user and redirect them to the login page
 *  * Or send back 403 (Forbidden) with no response body.
 *
 * Example usage:
 * ```
 * return res.forbidden();
 * ```
 */

module.exports = function forbidden(data) {

    // Get access to `req` and `res`
    var req = this.req;
    var res = this.res;

    // If no data was provided, respond with 403 Forbidden and no body.
    if (data === undefined) {
        return res.status(403).send();
    }

    // If the request wants JSON, send back the data with a 403 status code.
    if (req.wantsJSON) {
        return res.status(403).json(data);
    }

    // If the request wants HTML, send back the data with a 403 status code.
    return res.status(403).send(data);
};
