Skip to content

Commit

Permalink
permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
starlying committed Jan 6, 2020
1 parent befb6a4 commit 99f70f1
Show file tree
Hide file tree
Showing 15 changed files with 43 additions and 42 deletions.
8 changes: 4 additions & 4 deletions Controllers/Pages/PagesFieldsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public IHttpActionResult Get()

var formInfo = FormManager.GetFormInfoByGet(request);
if (formInfo == null) return NotFound();
if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(formInfo.SiteId, FormUtils.PluginId)) return Unauthorized();
if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(formInfo.SiteId, FormUtils.MenuFormsPermission)) return Unauthorized();

var adminToken = Context.AdminApi.GetAccessToken(request.AdminId, request.AdminName, TimeSpan.FromDays(1));

Expand Down Expand Up @@ -64,7 +64,7 @@ public IHttpActionResult Delete()

var formInfo = FormManager.GetFormInfoByGet(request);
if (formInfo == null) return NotFound();
if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(formInfo.SiteId, FormUtils.PluginId)) return Unauthorized();
if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(formInfo.SiteId, FormUtils.MenuFormsPermission)) return Unauthorized();

var fieldId = request.GetQueryInt("fieldId");
FieldManager.Repository.Delete(formInfo.Id, fieldId);
Expand Down Expand Up @@ -103,7 +103,7 @@ public IHttpActionResult Export()

var formInfo = FormManager.GetFormInfoByPost(request);
if (formInfo == null) return NotFound();
if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(formInfo.SiteId, FormUtils.PluginId)) return Unauthorized();
if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(formInfo.SiteId, FormUtils.MenuFormsPermission)) return Unauthorized();

//var fileName = FieldManager.Export(formInfo.Id);\

Expand Down Expand Up @@ -140,7 +140,7 @@ public IHttpActionResult Import()

var formInfo = FormManager.GetFormInfoByGet(request);
if (formInfo == null) return NotFound();
if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(formInfo.SiteId, FormUtils.PluginId)) return Unauthorized();
if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(formInfo.SiteId, FormUtils.MenuFormsPermission)) return Unauthorized();

foreach (string name in HttpContext.Current.Request.Files)
{
Expand Down
4 changes: 2 additions & 2 deletions Controllers/Pages/PagesFieldsLayerModelController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public IHttpActionResult Get()

var formInfo = FormManager.GetFormInfoByGet(request);
if (formInfo == null) return NotFound();
if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(formInfo.SiteId, FormUtils.PluginId)) return Unauthorized();
if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(formInfo.SiteId, FormUtils.MenuFormsPermission)) return Unauthorized();

var fieldId = request.GetQueryInt("fieldId");
var fieldInfo = FieldManager.GetFieldInfo(formInfo.Id, fieldId) ?? new FieldInfo();
Expand Down Expand Up @@ -76,7 +76,7 @@ public IHttpActionResult Submit()

var formInfo = FormManager.GetFormInfoByPost(request);
if (formInfo == null) return NotFound();
if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(formInfo.SiteId, FormUtils.PluginId)) return Unauthorized();
if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(formInfo.SiteId, FormUtils.MenuFormsPermission)) return Unauthorized();

var fieldId = request.GetPostInt("fieldId");
var isRapid = request.GetPostBool("isRapid");
Expand Down
4 changes: 2 additions & 2 deletions Controllers/Pages/PagesFieldsLayerValidateController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public IHttpActionResult Get()

var formInfo = FormManager.GetFormInfoByGet(request);
if (formInfo == null) return NotFound();
if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(formInfo.SiteId, FormUtils.PluginId)) return Unauthorized();
if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(formInfo.SiteId, FormUtils.MenuFormsPermission)) return Unauthorized();

var fieldId = request.GetQueryInt("fieldId");
var fieldInfo = FieldManager.GetFieldInfo(formInfo.Id, fieldId);
Expand Down Expand Up @@ -51,7 +51,7 @@ public IHttpActionResult Submit()

var formInfo = FormManager.GetFormInfoByPost(request);
if (formInfo == null) return NotFound();
if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(formInfo.SiteId, FormUtils.PluginId)) return Unauthorized();
if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(formInfo.SiteId, FormUtils.MenuFormsPermission)) return Unauthorized();

var fieldId = request.GetPostInt("fieldId");
var value = request.GetPostString("value");
Expand Down
16 changes: 8 additions & 8 deletions Controllers/Pages/PagesFormsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public IHttpActionResult Get()

var siteId = request.GetQueryInt("siteId");
if (!request.IsAdminLoggin ||
!request.AdminPermissions.HasSitePermissions(siteId, FormUtils.PluginId))
!request.AdminPermissions.HasSitePermissions(siteId, FormUtils.MenuFormsPermission))
{
return Unauthorized();
}
Expand Down Expand Up @@ -57,7 +57,7 @@ public IHttpActionResult Delete()

var siteId = request.GetQueryInt("siteId");
if (!request.IsAdminLoggin ||
!request.AdminPermissions.HasSitePermissions(siteId, FormUtils.PluginId))
!request.AdminPermissions.HasSitePermissions(siteId, FormUtils.MenuFormsPermission))
{
return Unauthorized();
}
Expand Down Expand Up @@ -86,7 +86,7 @@ public IHttpActionResult Add()

var siteId = request.GetPostInt("siteId");
if (!request.IsAdminLoggin ||
!request.AdminPermissions.HasSitePermissions(siteId, FormUtils.PluginId))
!request.AdminPermissions.HasSitePermissions(siteId, FormUtils.MenuFormsPermission))
{
return Unauthorized();
}
Expand Down Expand Up @@ -121,7 +121,7 @@ public IHttpActionResult Edit()

var siteId = request.GetPostInt("siteId");
if (!request.IsAdminLoggin ||
!request.AdminPermissions.HasSitePermissions(siteId, FormUtils.PluginId))
!request.AdminPermissions.HasSitePermissions(siteId, FormUtils.MenuFormsPermission))
{
return Unauthorized();
}
Expand Down Expand Up @@ -153,7 +153,7 @@ public IHttpActionResult Up()

var siteId = request.GetPostInt("siteId");
if (!request.IsAdminLoggin ||
!request.AdminPermissions.HasSitePermissions(siteId, FormUtils.PluginId))
!request.AdminPermissions.HasSitePermissions(siteId, FormUtils.MenuFormsPermission))
{
return Unauthorized();
}
Expand Down Expand Up @@ -182,7 +182,7 @@ public IHttpActionResult Down()

var siteId = request.GetPostInt("siteId");
if (!request.IsAdminLoggin ||
!request.AdminPermissions.HasSitePermissions(siteId, FormUtils.PluginId))
!request.AdminPermissions.HasSitePermissions(siteId, FormUtils.MenuFormsPermission))
{
return Unauthorized();
}
Expand Down Expand Up @@ -211,7 +211,7 @@ public IHttpActionResult Export()

var formInfo = FormManager.GetFormInfoByPost(request);
if (formInfo == null) return NotFound();
if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(formInfo.SiteId, FormUtils.PluginId)) return Unauthorized();
if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(formInfo.SiteId, FormUtils.MenuFormsPermission)) return Unauthorized();

var fileName = $"{formInfo.Title}.zip";
var directoryPath = Context.UtilsApi.GetTemporaryFilesPath("form");
Expand Down Expand Up @@ -242,7 +242,7 @@ public IHttpActionResult Import()
var request = Context.AuthenticatedRequest;
var siteId = request.GetQueryInt("siteId");

if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(siteId, FormUtils.PluginId)) return Unauthorized();
if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(siteId, FormUtils.MenuFormsPermission)) return Unauthorized();

foreach (string name in HttpContext.Current.Request.Files)
{
Expand Down
8 changes: 4 additions & 4 deletions Controllers/Pages/PagesLogAddController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public IHttpActionResult Get()

var formInfo = FormManager.GetFormInfoByGet(request);
if (formInfo == null) return NotFound();
if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(formInfo.SiteId, FormUtils.PluginId)) return Unauthorized();
if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(formInfo.SiteId, FormUtils.MenuFormsPermission)) return Unauthorized();

var logId = request.GetQueryInt("logId");
var fieldInfoList = FieldManager.GetFieldInfoList(formInfo.Id);
Expand Down Expand Up @@ -105,7 +105,7 @@ public IHttpActionResult UploadFile()
var fieldId = request.GetQueryInt("fieldId");

if (!request.IsAdminLoggin ||
!request.AdminPermissions.HasSitePermissions(siteId, FormUtils.PluginId))
!request.AdminPermissions.HasSitePermissions(siteId, FormUtils.MenuFormsPermission))
{
return Unauthorized();
}
Expand Down Expand Up @@ -155,7 +155,7 @@ public IHttpActionResult DeleteFile()
var fieldId = request.GetQueryInt("fieldId");

if (!request.IsAdminLoggin ||
!request.AdminPermissions.HasSitePermissions(siteId, FormUtils.PluginId))
!request.AdminPermissions.HasSitePermissions(siteId, FormUtils.MenuFormsPermission))
{
return Unauthorized();
}
Expand Down Expand Up @@ -186,7 +186,7 @@ public IHttpActionResult Submit()

var formInfo = FormManager.GetFormInfoByPost(request);
if (formInfo == null) return NotFound();
if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(formInfo.SiteId, FormUtils.PluginId)) return Unauthorized();
if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(formInfo.SiteId, FormUtils.MenuFormsPermission)) return Unauthorized();

var logId = request.GetPostInt("logId");

Expand Down
12 changes: 6 additions & 6 deletions Controllers/Pages/PagesLogsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public IHttpActionResult Get()

var formInfo = FormManager.GetFormInfoByGet(request);
if (formInfo == null) return NotFound();
if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(formInfo.SiteId, FormUtils.PluginId)) return Unauthorized();
if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(formInfo.SiteId, FormUtils.MenuFormsPermission)) return Unauthorized();

var fieldInfoList = FieldManager.GetFieldInfoList(formInfo.Id);
var listAttributeNames = FormUtils.StringCollectionToStringList(formInfo.ListAttributeNames);
Expand Down Expand Up @@ -69,7 +69,7 @@ public IHttpActionResult Delete()

var formInfo = FormManager.GetFormInfoByGet(request);
if (formInfo == null) return NotFound();
if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(formInfo.SiteId, FormUtils.PluginId)) return Unauthorized();
if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(formInfo.SiteId, FormUtils.MenuFormsPermission)) return Unauthorized();

var logId = request.GetQueryInt("logId");
var logInfo = LogManager.Repository.GetLogInfo(logId);
Expand Down Expand Up @@ -113,7 +113,7 @@ public IHttpActionResult Export()

var formInfo = FormManager.GetFormInfoByPost(request);
if (formInfo == null) return NotFound();
if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(formInfo.SiteId, FormUtils.PluginId)) return Unauthorized();
if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(formInfo.SiteId, FormUtils.MenuFormsPermission)) return Unauthorized();

var fieldInfoList = FieldManager.GetFieldInfoList(formInfo.Id);
var logs = LogManager.Repository.GetAllLogInfoList(formInfo);
Expand Down Expand Up @@ -147,8 +147,8 @@ public IHttpActionResult Export()
}

var fileName = $"{formInfo.Title}.csv";
CsvUtils.Export(Context.PluginApi.GetPluginPath(FormUtils.PluginId, fileName), head, rows);
var downloadUrl = Context.PluginApi.GetPluginUrl(FormUtils.PluginId, fileName);
CsvUtils.Export(Context.PluginApi.GetPluginPath(FormUtils.MenuFormsPermission, fileName), head, rows);
var downloadUrl = Context.PluginApi.GetPluginUrl(FormUtils.MenuFormsPermission, fileName);

return Ok(new
{
Expand All @@ -170,7 +170,7 @@ public IHttpActionResult Visible()

var formInfo = FormManager.GetFormInfoByPost(request);
if (formInfo == null) return NotFound();
if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(formInfo.SiteId, FormUtils.PluginId)) return Unauthorized();
if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(formInfo.SiteId, FormUtils.MenuFormsPermission)) return Unauthorized();

var attributeName = request.GetPostString("attributeName");

Expand Down
4 changes: 2 additions & 2 deletions Controllers/Pages/PagesLogsLayerReplyController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public IHttpActionResult Get()

var formInfo = FormManager.GetFormInfoByGet(request);
if (formInfo == null) return NotFound();
if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(formInfo.SiteId, FormUtils.PluginId)) return Unauthorized();
if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(formInfo.SiteId, FormUtils.MenuFormsPermission)) return Unauthorized();

var logId = request.GetQueryInt("logId");
var fieldInfoList = FieldManager.GetFieldInfoList(formInfo.Id);
Expand Down Expand Up @@ -55,7 +55,7 @@ public IHttpActionResult Submit()

var formInfo = FormManager.GetFormInfoByPost(request);
if (formInfo == null) return NotFound();
if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(formInfo.SiteId, FormUtils.PluginId)) return Unauthorized();
if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(formInfo.SiteId, FormUtils.MenuFormsPermission)) return Unauthorized();

var logId = request.GetPostInt("logId");
var logInfo = LogManager.Repository.GetLogInfo(logId);
Expand Down
4 changes: 2 additions & 2 deletions Controllers/Pages/PagesSettingsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public IHttpActionResult Get()

var formInfo = FormManager.GetFormInfoByGet(request);
if (formInfo == null) return NotFound();
if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(formInfo.SiteId, FormUtils.PluginId)) return Unauthorized();
if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(formInfo.SiteId, FormUtils.MenuFormsPermission)) return Unauthorized();

var fieldInfoList = FieldManager.GetFieldInfoList(formInfo.Id);

Expand Down Expand Up @@ -58,7 +58,7 @@ public IHttpActionResult Submit()

var formInfo = FormManager.GetFormInfoByPost(request);
if (formInfo == null) return NotFound();
if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(formInfo.SiteId, FormUtils.PluginId)) return Unauthorized();
if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(formInfo.SiteId, FormUtils.MenuFormsPermission)) return Unauthorized();

var type = request.GetPostString("type");
if (FormUtils.EqualsIgnoreCase(type, nameof(FormInfo.IsClosed)))
Expand Down
4 changes: 2 additions & 2 deletions Controllers/Pages/PagesTemplateHtmlController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public IHttpActionResult GetTemplateInfo()
var request = Context.AuthenticatedRequest;

var siteId = request.GetQueryInt("siteId");
if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(siteId, FormUtils.PluginId)) return Unauthorized();
if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(siteId, FormUtils.MenuTemplatesPermission)) return Unauthorized();

var type = request.GetQueryString("type");
var name = request.GetQueryString("name");
Expand Down Expand Up @@ -55,7 +55,7 @@ public IHttpActionResult Submit()
var request = Context.AuthenticatedRequest;

var siteId = request.GetQueryInt("siteId");
if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(siteId, FormUtils.PluginId)) return Unauthorized();
if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(siteId, FormUtils.MenuTemplatesPermission)) return Unauthorized();

var name = request.GetPostString("name");
var templateHtml = request.GetPostString("templateHtml");
Expand Down
4 changes: 2 additions & 2 deletions Controllers/Pages/PagesTemplatesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public IHttpActionResult List()
var request = Context.AuthenticatedRequest;

var siteId = request.GetQueryInt("siteId");
if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(siteId, FormUtils.PluginId)) return Unauthorized();
if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(siteId, FormUtils.MenuTemplatesPermission)) return Unauthorized();

var type = request.GetQueryString("type");

Expand All @@ -42,7 +42,7 @@ public IHttpActionResult Delete()
var request = Context.AuthenticatedRequest;

var siteId = request.GetQueryInt("siteId");
if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(siteId, FormUtils.PluginId)) return Unauthorized();
if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(siteId, FormUtils.MenuTemplatesPermission)) return Unauthorized();

var type = request.GetQueryString("type");
var name = request.GetQueryString("name");
Expand Down
Loading

0 comments on commit 99f70f1

Please sign in to comment.