mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-04-19 19:14:51 +00:00
Add button and controller to remove user avatar (#1057)
Some checks failed
Some checks failed
* Add button and controller to remove user avatar * Update ProjectLighthouse.Servers.Website/Controllers/Admin/AdminUserController.cs Suggestion provided to add logging, a return, and sending a notification to the affected user Co-authored-by: Josh <josh@slendy.pw> * Update ProjectLighthouse.Servers.Website/Controllers/Admin/AdminUserController.cs Co-authored-by: Josh <josh@slendy.pw> --------- Co-authored-by: Josh <josh@slendy.pw>
This commit is contained in:
parent
0af064ad1e
commit
917cccb3b0
2 changed files with 28 additions and 1 deletions
|
@ -143,7 +143,29 @@ public class AdminUserController : ControllerBase
|
|||
}
|
||||
|
||||
/// <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 = "";
|
||||
|
||||
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)
|
||||
|
|
|
@ -337,6 +337,11 @@ else
|
|||
<span>Wipe User'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">
|
||||
|
|
Loading…
Add table
Reference in a new issue