diff --git a/ProjectLighthouse.Servers.Website/Controllers/Admin/AdminUserController.cs b/ProjectLighthouse.Servers.Website/Controllers/Admin/AdminUserController.cs index 55db420c1..b4b0ec983 100644 --- a/ProjectLighthouse.Servers.Website/Controllers/Admin/AdminUserController.cs +++ b/ProjectLighthouse.Servers.Website/Controllers/Admin/AdminUserController.cs @@ -143,7 +143,29 @@ public async Task WipeScores([FromRoute] int id) } /// - /// Forces the email verification of a user. + /// Deletes the user's current avatar. Can prevent crashes in-game, or just be used to remove images that break guidelines. + /// + [HttpGet("wipeAvatar")] + public async Task WipeAvatar([FromRoute] int id) + { + UserEntity? user = this.database.UserFromWebRequest(this.Request); + if (user == null || !user.IsModerator) return this.NotFound(); + + UserEntity? targetedUser = await this.database.Users.FirstOrDefaultAsync(u => u.UserId == id); + if (targetedUser == null) return this.NotFound(); + + targetedUser.IconHash = ""; + + await this.database.SaveChangesAsync(); + Logger.Success($"Reset profile picture for {targetedUser.Username} (id:{targetedUser.UserId})", LogArea.Admin); + + await this.database.SendNotification(targetedUser.UserId, "Your profile picture has been reset by a moderator."); + + return this.Redirect($"/user/{targetedUser.UserId}"); + } + + /// + /// Forces the email verification of a user. /// [HttpGet("forceVerifyEmail")] public async Task ForceVerifyEmail([FromRoute] int id) diff --git a/ProjectLighthouse.Servers.Website/Pages/UserPage.cshtml b/ProjectLighthouse.Servers.Website/Pages/UserPage.cshtml index 98c23fcdb..84d9e0bab 100644 --- a/ProjectLighthouse.Servers.Website/Pages/UserPage.cshtml +++ b/ProjectLighthouse.Servers.Website/Pages/UserPage.cshtml @@ -337,6 +337,11 @@ else Wipe User's Scores + + + Remove User Avatar + + @if (!Model.CommentsDisabledByModerator) {