/// <summary> /// </summary> /// <param name="Username"></param> /// <returns></returns> public User CreateUser(string Username) { User user = FindUser(Username); if (user != null) { return(user); } user = new User(); user.Username = Username; user.Groups.Add("All Users"); // First user is always an administrator. if (Users.Count == 0) { user.Groups.Add("Administrators"); } Users.Add(user); Logger.Log(LogLevel.Info, LogCategory.Users, "Added new user '{0}'", Username); UsersUpdated?.Invoke(); return(user); }
/// <summary> /// </summary> /// <param name="Username"></param> /// <returns></returns> public void DeleteUser(User user) { Users.Remove(user); Logger.Log(LogLevel.Info, LogCategory.Users, "Deleted user '{0}'", user.Username); PermissionsUpdated?.Invoke(user); UsersUpdated?.Invoke(); }
private void _usersUpdated(List <PublicUser> list) { var newUsers = list.Except(Users).ToList(); if (newUsers.Count == 0) { return; } Users.AddRange(newUsers); UsersUpdated?.Invoke(newUsers); }
public async Task <User> UpdateUser(User user) { var users = await GetUsers(); await _localStorage.SetItemAsync("users", users.Where(u => u.Name != user.Name).Append(user).ToList()); await SetActiveUser(user); UsersUpdated?.Invoke(); return(user); }
/// <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); } } }