Ejemplo n.º 1
0
        public void EditRole(Role role)
        {
            if (!_authorizer.Authorize(Permissions.RoleManager))
                throw new QsTechException(string.Format("û��{0}��Ȩ��!", Permissions.RoleManager.Description));

            _rolesRepo.Update(role);
        }
Ejemplo n.º 2
0
 public ListRoleModel(Role role)
 {
     Id = role.Id;
     Name = role.Name;
     Description = role.Description;
     Category = role.Category;
     BelongsTo = role.BelongsTo;
 }
Ejemplo n.º 3
0
 public EditRoleModel(Role role)
 {
     Original = role;
     Id = role.Id;
     Name = role.Name;
     Description = role.Description;
     Category = role.Category;
     BelongsTo = role.BelongsTo;
 }
Ejemplo n.º 4
0
 void ResetUserPermissionsCache(Role role)
 {
     _eventManager.Trigger<IRolePermissionsChangedEventHandler>(caller =>
     {
         caller.ResetUserPermissionsCache(role.Owners.ToArray());
     });
 }
Ejemplo n.º 5
0
 public bool TryGetRole(string name, out Role role)
 {
     role = null;
     try
     {
         role = _rolesRepo.Get(u => u.Name == name);
         return role != null;
     }
     catch (Exception ex)
     {
         Logger.Information(ex, string.Format("���ݽ�ɫ�� {0} ���ҽ�ɫʱ��������", name));
     }
     return false;
 }
Ejemplo n.º 6
0
 public ActionResult Create(CreateRoleModel model)
 {
     CheckPermission();
     if (ModelState.IsValid)
     {
         if (_roleService.ExistsRole(model.Name))
         {
             ModelState.AddModelError("Name", string.Format("角色名 {0} 已经存在", model.Name));
             return View(model);
         }
         Role newRole = new Role
         {
             Name = model.Name,
             Description = model.Description,
             Category = model.Category,
             BelongsTo = model.BelongsTo,
             Enabled = true
         };
         _roleService.AddRole(newRole);
         return RedirectToAction("Edit", new { id = newRole.Id });
     }
     model.BelongsArray = _belongsSystemService.GetSystems();
     return View(model);
 }
Ejemplo n.º 7
0
 void LoadPermissions(EditRoleModel model, Role role)
 {
     List<ModulePermissionModel> permissionModels = new List<ModulePermissionModel>();
     var modules = _moduleManager.GetAvailableModules();
     foreach (var module in modules)
     {
         var permissions = _permissionManager.GetPermissions(module.Id);
         if (!permissions.Any())
         {
             continue;
         }
         permissionModels.Add(new ModulePermissionModel
         {
             ModuleDescriptor = module,
             Permissions = permissions.Select(p => new PermissionModel
             {
                 PermissionName = _translation.T(p.Name),
                 PermissionDescription = p.Description,
                 Allow = role.Permissions != null && role.Permissions.Any(rp => rp == p.Name),
                 ImpliedPermissionString = p.ImpliedBy != null ? string.Join(",", p.ImpliedBy.Where(imp=>imp != null).Select(imp => imp.Name)) : string.Empty
             })
         });
     }
     model.Original = role;
     model.Permissions = permissionModels;
 }