/* * Block access to a copier if accessing outside of * operation hours. Additionally send an email alert * to admin to notify of attempted copier access during * a restricted period. * */ function deviceLoginHook(inputs, actions) { // Set the prohibited hours for weekdays var BEFORE_HOURS = 8; // 8am var AFTER_HOURS = 18; // 6pm // Also prohibit access over weekends // For reference: 0 = Sunday, 1 = Monday... 6 = Saturday var SUNDAY = 0; var SATURDAY = 6; var date = new Date(); var hour = date.getHours(); var day = date.getDay(); // check if accessing device outside of working hours if (hour >= AFTER_HOURS || hour < BEFORE_HOURS || day == SUNDAY || day == SATURDAY ) { // deny login actions.login.denyLoginAccess(); // send an alert email to admin var recipient = "admin@emailaddress.com"; var subject = "Device alert"; var body = "User " + inputs.user.username + " attempted to log into device " + inputs.device.deviceName + " during prohibited hours." ; actions.utils.sendEmail(recipient, subject, body); } }