/* jshint esversion: 6 */

const config = require('../../config.js'),
        accountManager = require('../models/accounts.js').accountManager;

module.exports.AccountController = {
    onRequest: function(req, res, srv) {
        if (req.urlObj.match(["account", "cguAccept"]) && req.method === "PUT") {
            req.account.dirty = true;
            req.account.cguReadAndAccepted = true;
            accountManager.save(req.account, () => {});
            res.writeHeader("204", "No Content");
            res.end();
        } else {
            srv.execTemplate(require('../template/_404.js'), req, res);
        }
    }
};

