PageRenderTime 22ms CodeModel.GetById 14ms app.highlight 5ms RepoModel.GetById 2ms 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
 1namespace 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
10    using Page = System.Web.UI.Page;
11
12    /// <summary>
13    /// The admin account roles.
14    /// </summary>
15    public partial class Roles : Page
16    {
17        #region Public Methods
18
19        protected void Page_Load(object sender, EventArgs e)
20        {
21            Security.DemandUserHasRight(AuthorizationCheck.HasAll, true, new[] {
22                BlogEngine.Core.Rights.AccessAdminPages,
23                BlogEngine.Core.Rights.ViewRoles });
24
25        }
26
27        /// <summary>
28        /// Gets the roles.
29        /// </summary>
30        /// <returns>The roles.</returns>
31        [WebMethod]
32        public static List<JsonRole> GetRoles()
33        {
34            if (!Security.IsAuthorizedTo(BlogEngine.Core.Rights.ViewRoles))
35                return new List<JsonRole>();
36
37            var roles = new List<JsonRole>();
38            roles.AddRange(System.Web.Security.Roles.GetAllRoles().Select(r => new JsonRole { RoleName = r, IsSystemRole = Security.IsSystemRole(r) }));
39            roles.Sort((r1, r2) => string.Compare(r1.RoleName, r2.RoleName));
40
41            return roles;
42        }
43
44        #endregion
45
46        #region Methods
47
48
49        #endregion
50    }
51}