mirror of
https://git.recroomarchive.org/RecRoomArchive/RRAC.git
synced 2026-09-09 07:01:24 -07:00
Initialize repository
Added basic info to get in game for like...August 2016 ;-; It's not much but it's a start
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user