/// <summary> /// /// </summary> /// <param name="user"></param> /// <param name="group"></param> public void RemoveUserFromGroup(User user, UserGroup group) { if (user.Groups.Contains(group.Name)) { user.Groups.Remove(group.Name); Logger.Log(LogLevel.Info, LogCategory.Users, "Removing user '{0}' from group '{1}'", user.Username, group.Name); PermissionsUpdated?.Invoke(user); UserGroupsUpdated?.Invoke(); UsersUpdated?.Invoke(); } }
/// <summary> /// /// </summary> /// <param name="user"></param> /// <param name="group"></param> public void AddUserToGroup(User user, UserGroup group) { if (!user.Groups.Contains(group.Name)) { user.Groups.Add(group.Name); Logger.Log(LogLevel.Info, LogCategory.Users, "Adding user '{0}' to group '{1}'", user.Username, group.Name); PermissionsUpdated?.Invoke(user); UserGroupsUpdated?.Invoke(); UsersUpdated?.Invoke(); } }
/// <summary> /// </summary> /// <param name="Username"></param> /// <returns></returns> public void RevokePermission(UserGroup Group, UserPermissionType Permission, string Path) { Group.Permissions.RevokePermission(Permission, Path); Logger.Log(LogLevel.Info, LogCategory.Users, "Revoked group '{0}' permission '{1}'", Group.Name, Permission.ToString()); UsersUpdated?.Invoke(); UserGroupsUpdated?.Invoke(); foreach (User user in Users) { if (user.Groups.Contains(Group.Name)) { PermissionsUpdated?.Invoke(user); } } }
/// <summary> /// </summary> /// <param name="group"></param> /// <returns></returns> public void DeleteGroup(UserGroup group) { UserGroups.Remove(group); Logger.Log(LogLevel.Info, LogCategory.Users, "Deleted user group '{0}'", group.Name); foreach (User user in Users) { if (user.Groups.Contains(group.Name)) { user.Groups.Remove(group.Name); PermissionsUpdated?.Invoke(user); } } UserGroupsUpdated?.Invoke(); }
/// <summary> /// </summary> /// <param name="Name"></param> /// <returns></returns> public UserGroup CreateGroup(string Name) { UserGroup group = FindGroup(Name); if (group != null) { return(group); } group = new UserGroup(); group.Name = Name; UserGroups.Add(group); Logger.Log(LogLevel.Info, LogCategory.Users, "Added new user group '{0}'", Name); UserGroupsUpdated?.Invoke(); return(group); }