/BlogEngine/BlogEngine.NET/admin/Users/Roles.aspx.cs
# · C# · 51 lines · 33 code · 11 blank · 7 comment · 1 complexity · 5f1d423f1b8312d68bb934a1a691b943 MD5 · raw file
- namespace Admin.Users
- {
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web.Services;
- using BlogEngine.Core;
- using BlogEngine.Core.Json;
-
- using Page = System.Web.UI.Page;
-
- /// <summary>
- /// The admin account roles.
- /// </summary>
- public partial class Roles : Page
- {
- #region Public Methods
-
- protected void Page_Load(object sender, EventArgs e)
- {
- Security.DemandUserHasRight(AuthorizationCheck.HasAll, true, new[] {
- BlogEngine.Core.Rights.AccessAdminPages,
- BlogEngine.Core.Rights.ViewRoles });
-
- }
-
- /// <summary>
- /// Gets the roles.
- /// </summary>
- /// <returns>The roles.</returns>
- [WebMethod]
- public static List<JsonRole> GetRoles()
- {
- if (!Security.IsAuthorizedTo(BlogEngine.Core.Rights.ViewRoles))
- return new List<JsonRole>();
-
- var roles = new List<JsonRole>();
- roles.AddRange(System.Web.Security.Roles.GetAllRoles().Select(r => new JsonRole { RoleName = r, IsSystemRole = Security.IsSystemRole(r) }));
- roles.Sort((r1, r2) => string.Compare(r1.RoleName, r2.RoleName));
-
- return roles;
- }
-
- #endregion
-
- #region Methods
-
-
- #endregion
- }
- }