Authorizations
This commit is contained in:
parent
205845fac7
commit
997c39703a
13 changed files with 34 additions and 28 deletions
|
|
@ -403,7 +403,7 @@ namespace Yavsc.Controllers
|
|||
}
|
||||
|
||||
|
||||
[Authorize(Roles = Constants.AdminGroupName)]
|
||||
[Authorize("AdministratorOnly")]
|
||||
public IActionResult Index()
|
||||
{
|
||||
IViewComponentHelper h;
|
||||
|
|
@ -411,7 +411,7 @@ namespace Yavsc.Controllers
|
|||
return View();
|
||||
}
|
||||
|
||||
[Authorize(Roles = Constants.AdminGroupName)]
|
||||
[Authorize("AdministratorOnly")]
|
||||
[Route("Account/UserList/{pageNum}/{len?}")]
|
||||
public async Task<IActionResult> UserList(int pageNum, int pageLen = defaultLen)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ namespace Yavsc.Controllers
|
|||
return Ok(new { message = "you owned it." });
|
||||
}
|
||||
|
||||
[Authorize(Roles = Constants.AdminGroupName)]
|
||||
[Authorize("AdministratorOnly")]
|
||||
[Produces("application/json")]
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -25,13 +25,13 @@ namespace Yavsc.Controllers
|
|||
public IActionResult GetBlog()
|
||||
{
|
||||
var data = applicationDbContext.BlogSpot.ToArray();
|
||||
return Ok(JsonConvert.SerializeObject(data, Formatting.None));
|
||||
return Ok(data);
|
||||
}
|
||||
|
||||
public IActionResult GetUsers()
|
||||
{
|
||||
var data = applicationDbContext.Users.ToArray();
|
||||
return Ok(JsonConvert.SerializeObject(data, Formatting.None));
|
||||
return Ok(data);
|
||||
}
|
||||
|
||||
public IActionResult ImportUsers(String usersJson)
|
||||
|
|
|
|||
|
|
@ -50,9 +50,8 @@ namespace Yavsc.Controllers
|
|||
private List<SelectListItem> GetEligibleParent(string code)
|
||||
{
|
||||
// eligibles are those
|
||||
// who are not in descendants
|
||||
// who are not in descendence
|
||||
|
||||
//
|
||||
var acts = _context.Activities.Where(
|
||||
a => a.Code != code
|
||||
).Select(a => new SelectListItem
|
||||
|
|
@ -68,13 +67,13 @@ namespace Yavsc.Controllers
|
|||
var pi = acts.FirstOrDefault(i => i.Value == existing.ParentCode);
|
||||
if (pi!=null) pi.Selected = true;
|
||||
else nullItem.Selected = true;
|
||||
RecFilterChild(acts, existing);
|
||||
RecursivelyFilterChild(acts, existing);
|
||||
return acts;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Filters a activity selection list
|
||||
/// in order to exculde any descendant
|
||||
/// in order to exclude any descendant
|
||||
/// from the eligible list at the <c>Parent</c> property.
|
||||
/// WARN! results in a infinite loop when
|
||||
/// data is corrupted and there is a circularity
|
||||
|
|
@ -82,22 +81,19 @@ namespace Yavsc.Controllers
|
|||
/// </summary>
|
||||
/// <param name="list"></param>
|
||||
/// <param name="activity"></param>
|
||||
private static void RecFilterChild(List<SelectListItem> list, Activity activity)
|
||||
private static void RecursivelyFilterChild(List<SelectListItem> list, Activity activity)
|
||||
{
|
||||
if (activity == null) return;
|
||||
if (activity.Children == null) return;
|
||||
if (list.Count == 0) return;
|
||||
foreach (var child in activity.Children)
|
||||
{
|
||||
RecFilterChild(list, child);
|
||||
RecursivelyFilterChild(list, child);
|
||||
var rem = list.FirstOrDefault(i => i.Value == child.Code);
|
||||
if (rem != null) list.Remove(rem);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// GET: Activity/Details/5
|
||||
public IActionResult Details(string id)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ using Yavsc.Server.Helpers;
|
|||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
[Authorize(Roles="Administrator")]
|
||||
[Authorize("AdministratorOnly")]
|
||||
public class SIRENExceptionsController : Controller
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ using Yavsc.Controllers.Generic;
|
|||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
[Authorize(Roles="Performer")]
|
||||
[Authorize("Performer")]
|
||||
public class BrusherProfileController : SettingsController<BrusherProfile>
|
||||
{
|
||||
public BrusherProfileController(ApplicationDbContext context) : base(context)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue