"use strict"; angular.module("vocabulary") .service("adminReports", ["$q", "HAS_REPORTS_ONLY_ACCESS", "MessageBox", "exceptionService", function ($q, HAS_REPORTS_ONLY_ACCESS, MessageBox, exceptionService) { return { alertIfReportsOnly: alertIfReportsOnly, hasReportsOnlyAccess: hasReportsOnlyAccess }; function alertIfReportsOnly() { if (HAS_REPORTS_ONLY_ACCESS){ return failAfterMessage(); } return $q.resolve(); } function hasReportsOnlyAccess() { return HAS_REPORTS_ONLY_ACCESS; } function failAfterMessage() { return displayMessage() .then(function () { throw exceptionService.getAuthorizationException("NOT AUTHORIZED"); }); } function displayMessage() { return MessageBox.show({ message: "You are authorized to access admin reports only.", responses: [ { confirm: true, label: 'OK' } ] }); } }]);