Add remaining project files
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
using DeluxeBackend.Models;
|
||||
using DeluxeBackend.Services;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace DeluxeBackend.Controllers.Accounts
|
||||
{
|
||||
[Route("Accounts/accountprivacysettings")]
|
||||
[ApiController]
|
||||
public class AccountPrivacySettingsController(ILiteDbService db, IJwtService jwt) : ControllerBase
|
||||
{
|
||||
[HttpGet("{accId}")]
|
||||
public async Task<IActionResult> AccountPrivacySettings(long accId)
|
||||
{
|
||||
|
||||
Account? account = db.Accounts.FindById(accId);
|
||||
|
||||
if (account == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return Ok(new
|
||||
{
|
||||
accountId = accId,
|
||||
isRecentHistoryVisible = account.IsRecentHistoryVisible
|
||||
});
|
||||
}
|
||||
[HttpGet("recenthistoryvisibility")]
|
||||
[Authorize(Roles = "gameClient")]
|
||||
public async Task<IActionResult> RecentHistoryVisibility([FromForm] bool isRecentHistoryVisible)
|
||||
{
|
||||
|
||||
LoginWithInfoResult? login = await jwt.GetLoginWithInfo(User);
|
||||
if (login == null) return Unauthorized();
|
||||
|
||||
Account account = login.Account;
|
||||
account.IsRecentHistoryVisible = isRecentHistoryVisible;
|
||||
db.Accounts.Update(account);
|
||||
|
||||
return Ok(new
|
||||
{
|
||||
Success = true
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user