mirror of
https://git.recroomarchive.org/RecRoomArchive/RRAC.git
synced 2026-09-08 06:31:25 -07:00
387ec7ba89
Added basic info to get in game for like...August 2016 ;-; It's not much but it's a start
37 lines
1.3 KiB
C#
37 lines
1.3 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using RecRoomArchive.Models.API.Players;
|
|
using RecRoomArchive.Models.Common;
|
|
using RecRoomArchive.Services;
|
|
using System.Text.Json;
|
|
|
|
namespace RecRoomArchive.Controllers.API.Players.V2
|
|
{
|
|
/// <summary>
|
|
/// Used to modify accounts / profiles in 2017-2019 although gets phased out as time goes on...
|
|
/// </summary>
|
|
[Route(template: "api/[controller]/v2")]
|
|
[ApiController]
|
|
public class PlayersController(FileService fileService) : ControllerBase
|
|
{
|
|
/// <summary>
|
|
/// Sets the players displayName
|
|
/// </summary>
|
|
/// <param name="name">The displayName the player is requesting</param>
|
|
/// <returns>OkResponse</returns>
|
|
[HttpPost(template: "displayName")]
|
|
public async Task<ActionResult<OkResponse>> SetDisplayName([FromForm(Name = "Name")] string name)
|
|
{
|
|
var profileData = fileService.GetData("profile.json");
|
|
if (profileData == null)
|
|
return BadRequest("Profile is not populated");
|
|
|
|
var profile = JsonSerializer.Deserialize<BaseProfile>(profileData)!;
|
|
|
|
profile.DisplayName = name;
|
|
|
|
fileService.SetData("profile.json", JsonSerializer.Serialize(profile));
|
|
|
|
return Ok(OkResponse.Ok());
|
|
}
|
|
}
|
|
} |