示例#1
0
        // GET: Permissions
        public ActionResult PermissionsForForm(Guid formId)
        {
            var formsSecurity = new UmbracoFormsSecurity();
            var form          = formsSecurity.PermissionsToForm(Services.UserService, formId);

            return(View("~/Views/Partials/Forms/Permissions.cshtml", form));
        }
 public IEnumerable <int> ListUserIds()
 {
     try
     {
         var formsSecurity = new UmbracoFormsSecurity();
         return(formsSecurity.GetAllUserIds(Services.UserService));
     }
     catch (Exception exception)
     {
         LogHelper.Error <UmbracoFormsSecurityApiController>(exception.Message, exception);
         throw;
     }
 }
 public void LockdownFormsSecurity()
 {
     try
     {
         var formsSecurity = new UmbracoFormsSecurity();
         formsSecurity.LockdownFormsSecurity(Services.UserService);
     }
     catch (Exception exception)
     {
         LogHelper.Error <UmbracoFormsSecurityApiController>(exception.Message, exception);
         throw;
     }
 }
 public void DenyAccessToFormsByDefault(int userId)
 {
     try
     {
         var formsSecurity = new UmbracoFormsSecurity();
         formsSecurity.RemoveManageFormsPermissions(userId, false);
         formsSecurity.RemoveDefaultAccessToForms(userId, false);
     }
     catch (Exception exception)
     {
         LogHelper.Error <UmbracoFormsSecurityApiController>(exception.Message, exception);
         throw;
     }
 }
        public ActionResult Download(string formId, string fileId, string filename)
        {
            try
            {
                var security = new UmbracoFormsSecurity();
                if (!security.UserHasAccessToForm(UmbracoContext.Security.CurrentUser.Id, new Guid(formId)))
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.Unauthorized));
                }

                var fileSystem = FileSystemProviderManager.Current.GetUnderlyingFileSystemProvider("media");
                if (fileSystem == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError));
                }

                return(DownloadFile(formId, fileId, filename, fileSystem));
            }
            catch (Exception exception)
            {
                LogHelper.Error <SecureFormUploadsController>(exception.Message, exception);
                throw;
            }
        }