summaryrefslogtreecommitdiff
path: root/DSACore/Controllers/TokensController.cs
blob: 1d49f44f01ca6d02e9d99ad1bbdb8d0c910dcde9 (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
26
27
28
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 (!Hubs.Users.Tokens.Exists(x => x.GetHashCode() == inttoken))
            {
                return NotFound();
            }

            var group = Hubs.Users.Tokens.Find(x => x.GetHashCode() == inttoken);
            return Ok(group);
        }
    }
}