Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add button and controller to remove user avatar #1057

Merged
merged 3 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,29 @@ public async Task<IActionResult> WipeScores([FromRoute] int id)
}

/// <summary>
/// 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.
/// </summary>
[HttpGet("wipeAvatar")]
public async Task<IActionResult> 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 = "";
FeTetra marked this conversation as resolved.
Show resolved Hide resolved

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}");
}

/// <summary>
/// Forces the email verification of a user.
/// </summary>
[HttpGet("forceVerifyEmail")]
public async Task<IActionResult> ForceVerifyEmail([FromRoute] int id)
Expand Down
5 changes: 5 additions & 0 deletions ProjectLighthouse.Servers.Website/Pages/UserPage.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,11 @@ else
<span>Wipe User&apos;s Scores</span>
</a>

<a class="ui yellow button" href="/moderation/user/@Model.ProfileUser.UserId/wipeAvatar">
<i class="trash alternate icon"></i>
<span>Remove User Avatar</span>
</a>

@if (!Model.CommentsDisabledByModerator)
{
<a class="ui yellow button" href="/moderation/newCase?type=@((int)CaseType.UserDisableComments)&affectedId=@Model.ProfileUser.UserId">
Expand Down
Loading