using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using CoviDok.Api; using CoviDok.Api.Request; using CoviDok.Api.Response; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; namespace CoviDok.Controllers { [Route("api/[controller]")] [ApiController] public class AuthController : ControllerBase { // POST: /api/Auth/login [HttpPost("login")] public async Task> PostLogin(AuthLogin authLogin) { AuthIdentity authIdentity = new AuthIdentity(); if (authLogin.Email == "a" && authLogin.Password == "a") { authIdentity.FirstName = "Sajt"; authIdentity.LastName = "Osperec"; authIdentity.Id = "asdfasdfadf"; authIdentity.Role = Api.Role.Doc; return authIdentity; } return Unauthorized(); } // POST: /api/Auth/register [HttpPost("register")] public async Task> PostRegister(AuthRegistration authRegistration) { GenericResponse genericResponse = new GenericResponse(); if (authRegistration.Email == "a") { genericResponse.Status = Status.Error; genericResponse.Body["reason"] = authRegistration.Email + " is already registered!"; } else if (authRegistration.Password == "1") { genericResponse.Status = Status.Error; genericResponse.Body["reason"] = "Password dows not meet complexity requirements!"; } else { genericResponse.Status = Status.Success; } return genericResponse; } // POST /api/Auth/child [HttpPost("child")] public async Task> PostAddChild(AuthChild authChild) { GenericResponse genericResponse = new GenericResponse(); if (authChild.SocSecNum == "111111111") { genericResponse.Status = Status.Error; genericResponse.Body["reason"] = "SSN Already exists!"; } else { genericResponse.Status = Status.Success; genericResponse.Body["childID"] = "asdfaasdas"; } return genericResponse; } } }