"use strict";

module.exports = {
    restrictAccess: function (record, keys) {
        if (!keys) {
            return null;
        }
        var keyIds = record.systemHeader ? record.systemHeader.keyIds : null;
        if (keyIds) {
            var temps = keys;
            var type = typeof  keys;
            if (type === 'string') {
                temps = keys.split(',');
            }

            for (var idx = 0; idx < temps.length; idx++) {
                for (var id = 0; id < keyIds.length; id++) {
                    if (temps[idx] === keyIds[id]) {
                        return record;
                    }
                }
            }
        }

        return record;
    }
};