mirror of
https://git.recroomarchive.org/RecRoomArchive/RRAC.git
synced 2026-09-08 22:51:26 -07:00
More changes...
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using RecRoomArchive.Models.API.Platform;
|
||||
using RecRoomArchive.Models.API.Players;
|
||||
using RecRoomArchive.Services;
|
||||
|
||||
namespace RecRoomArchive.Controllers.API.PlatformLogin.V1
|
||||
{
|
||||
[Route("api/[controller]/v1")]
|
||||
[ApiController]
|
||||
public class PlatformLoginController(AccountService accountService) : ControllerBase
|
||||
{
|
||||
[HttpPost(template: "profiles")]
|
||||
public async Task<ActionResult<List<BaseProfile>>> GetProfiles([FromForm(Name = "Platform")] PlatformType platform, [FromForm(Name = "PlatformId")] ulong platformId)
|
||||
{
|
||||
if (!accountService.AccountExists())
|
||||
{
|
||||
accountService.CreateAccount();
|
||||
}
|
||||
|
||||
var profile = accountService.GetSelfAccount();
|
||||
if (profile == null)
|
||||
return BadRequest("Please relaunch RRAC and re-run setup");
|
||||
|
||||
List<BaseProfile> profiles = [profile];
|
||||
|
||||
return Ok(profiles);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,7 @@ namespace RecRoomArchive.Controllers.API.PlatformLogin.V2
|
||||
accountService.CreateAccount(username);
|
||||
}
|
||||
|
||||
var accountId = accountService.GetSelfAccount()!.Id;
|
||||
var accountId = accountService.GetSelfAccountId()!.Value;
|
||||
|
||||
return Ok(new BaseLoginResponse
|
||||
{
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using RecRoomArchive.Models.API.PlatformLogin.Requests;
|
||||
using RecRoomArchive.Models.API.PlatformLogin.Responses;
|
||||
using RecRoomArchive.Services;
|
||||
|
||||
namespace RecRoomArchive.Controllers.API.PlatformLogin.V5
|
||||
{
|
||||
/// <summary>
|
||||
/// Used to login to accounts on Rec Room
|
||||
/// </summary>
|
||||
[Route(template: "api/[controller]/v5")]
|
||||
[ApiController]
|
||||
public class PlatformLoginController(AppVersionService appVersionService, AccountService accountService, AuthorizationService authorizationService) : ControllerBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Checks if the appVersion provided is allowed to play (which it most certainly will be unless its a weird build or someone messed with it)
|
||||
/// </summary>
|
||||
/// <returns>An Ok response if the version is valid, Forbid if it is not. Forbid will yield the client displaying "Rec Room Update Required" soo maybe don't</returns>
|
||||
[HttpPost]
|
||||
public async Task<ActionResult> Login([FromForm] BaseLoginRequest loginRequest)
|
||||
{
|
||||
var username = loginRequest.Name ?? string.Empty;
|
||||
|
||||
var buildTimestamp = loginRequest.BuildTimestamp;
|
||||
|
||||
await appVersionService.StoreBuildTimestamp(buildTimestamp);
|
||||
|
||||
// See if a profile exists yet...
|
||||
if (!accountService.AccountExists())
|
||||
{
|
||||
// ...if not, create it!
|
||||
accountService.CreateAccount(username);
|
||||
}
|
||||
|
||||
var accountId = accountService.GetSelfAccountId()!.Value;
|
||||
|
||||
return Ok(new BaseLoginResponse
|
||||
{
|
||||
Token = authorizationService.GenerateToken(accountId),
|
||||
PlayerId = accountId
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user