mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-29 16:38:37 +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>
|
/// <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>
|
/// </summary>
|
||||||
[HttpGet("forceVerifyEmail")]
|
[HttpGet("forceVerifyEmail")]
|
||||||
public async Task<IActionResult> ForceVerifyEmail([FromRoute] int id)
|
public async Task<IActionResult> ForceVerifyEmail([FromRoute] int id)
|
||||||
|
|
|
@ -337,6 +337,11 @@ else
|
||||||
<span>Wipe User's Scores</span>
|
<span>Wipe User's Scores</span>
|
||||||
</a>
|
</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)
|
@if (!Model.CommentsDisabledByModerator)
|
||||||
{
|
{
|
||||||
<a class="ui yellow button" href="/moderation/newCase?type=@((int)CaseType.UserDisableComments)&affectedId=@Model.ProfileUser.UserId">
|
<a class="ui yellow button" href="/moderation/newCase?type=@((int)CaseType.UserDisableComments)&affectedId=@Model.ProfileUser.UserId">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue