blob: a85cabe4a7cd8a05ebe53bf0d8d407e214a27cc5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
using DSACore.Hubs;
using Microsoft.AspNetCore.Mvc;
namespace DSACore.Controllers
{
[Route("lobby/[controller]")]
[ApiController]
public class TokensController : Controller
{
// GET
[HttpGet("{token}")]
public ActionResult<string> Get(string token)
{
if (!int.TryParse(token, out var intToken))
return BadRequest("The token has to be a 32 bit unsigned integer");
if (intToken == 42) return Ok("Scribble");
if (!Users.Tokens.Exists(x => x.GetHashCode() == intToken)) return NotFound();
var group = Users.Tokens.Find(x => x.GetHashCode() == intToken);
return Ok(group.Group);
}
}
}
|