mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-05-17 23:22:27 +00:00
Move servers to LBPU.PL.Servers
This commit is contained in:
parent
545b5a0709
commit
b2ec7eae57
116 changed files with 173 additions and 162 deletions
|
@ -1,35 +0,0 @@
|
|||
#nullable enable
|
||||
using LBPUnion.ProjectLighthouse.Types;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Website.Controllers.Admin;
|
||||
|
||||
[ApiController]
|
||||
[Route("admin/user/{id:int}")]
|
||||
public class AdminUserController : ControllerBase
|
||||
{
|
||||
private readonly Database database;
|
||||
|
||||
public AdminUserController(Database database)
|
||||
{
|
||||
this.database = database;
|
||||
}
|
||||
|
||||
[HttpGet("unban")]
|
||||
public async Task<IActionResult> UnbanUser([FromRoute] int id)
|
||||
{
|
||||
User? user = this.database.UserFromWebRequest(this.Request);
|
||||
if (user == null || !user.IsAdmin) return this.NotFound();
|
||||
|
||||
User? targetedUser = await this.database.Users.FirstOrDefaultAsync(u => u.UserId == id);
|
||||
|
||||
if (targetedUser == null) return this.NotFound();
|
||||
|
||||
targetedUser.Banned = false;
|
||||
targetedUser.BannedReason = null;
|
||||
|
||||
await this.database.SaveChangesAsync();
|
||||
return this.Redirect($"/user/{targetedUser.UserId}");
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue