blob: f1ddb37c988f94ef6c0da852323541fe03880291 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
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);
}
}
}
|