1
0
Fork 0
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.1 KiB

using Microsoft.AspNetCore.Mvc;
using PhilExampleCrawler.Common.Models;
using PhilExampleCrawler.DataBase;
using PhilExampleCrawler.DataBase.Models;
namespace WebAPI.Controllers
{
[ApiController]
[Route("[controller]")]
public class UserController : ControllerBase
{
private readonly ILogger<UserController> _logger;
public UserController(ILogger<UserController> logger)
{
_logger = logger;
}
[HttpGet(Name = "GetUser")]
public async Task<User?> GetAsync(int userID)
{
var user = await ThreadSafeCache.GetUserAsync(userID);
return user;
}
[HttpPost(Name = "RegisterUser")]
public async Task<User?> PostAsync(string authCode, string phoneNumber, bool optin_telegram)
{
if (authCode == null)
return null;
if (optin_telegram && phoneNumber == null)
return null;
User? user = await ThreadSafeCache.AddUserAsync(authCode, phoneNumber, optin_telegram);
return user;
}
}
}