PageRenderTime 56ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/BlogEngine/BlogEngine.NET/admin/Users/Roles.aspx.cs

#
C# | 51 lines | 33 code | 11 blank | 7 comment | 1 complexity | 5f1d423f1b8312d68bb934a1a691b943 MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0, BSD-3-Clause
  1. namespace Admin.Users
  2. {
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Web.Services;
  7. using BlogEngine.Core;
  8. using BlogEngine.Core.Json;
  9. using Page = System.Web.UI.Page;
  10. /// <summary>
  11. /// The admin account roles.
  12. /// </summary>
  13. public partial class Roles : Page
  14. {
  15. #region Public Methods
  16. protected void Page_Load(object sender, EventArgs e)
  17. {
  18. Security.DemandUserHasRight(AuthorizationCheck.HasAll, true, new[] {
  19. BlogEngine.Core.Rights.AccessAdminPages,
  20. BlogEngine.Core.Rights.ViewRoles });
  21. }
  22. /// <summary>
  23. /// Gets the roles.
  24. /// </summary>
  25. /// <returns>The roles.</returns>
  26. [WebMethod]
  27. public static List<JsonRole> GetRoles()
  28. {
  29. if (!Security.IsAuthorizedTo(BlogEngine.Core.Rights.ViewRoles))
  30. return new List<JsonRole>();
  31. var roles = new List<JsonRole>();
  32. roles.AddRange(System.Web.Security.Roles.GetAllRoles().Select(r => new JsonRole { RoleName = r, IsSystemRole = Security.IsSystemRole(r) }));
  33. roles.Sort((r1, r2) => string.Compare(r1.RoleName, r2.RoleName));
  34. return roles;
  35. }
  36. #endregion
  37. #region Methods
  38. #endregion
  39. }
  40. }