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(); authIdentity.FirstName = "Sajt"; authIdentity.LastName = "Osperec"; authIdentity.Id = "asdfasdfadf"; //SessionID if (authLogin.Email == "a@domain.tld" && authLogin.Password == "a") { authIdentity.Role = Role.Doc; return authIdentity; } if (authLogin.Email == "b@domain.tld" && authLogin.Password == "b") { authIdentity.Role = Role.Ast; return authIdentity; } if (authLogin.Email == "c@domain.tld" && authLogin.Password == "c") { authIdentity.Role = Role.Par; return authIdentity; } return Unauthorized(); } // POST: /api/Auth/register [HttpPost("register")] public async Task> PostRegister(AuthRegistration authRegistration) { // System.Diagnostics.Debug.WriteLine(authRegistration.ToString()); // Validate Email GenericResponse genericResponse = new GenericResponse(); if (authRegistration.Email == "a@domain.tld") { 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 does not meet complexity requirements!"; } return genericResponse; } // POST /api/Auth/child [HttpPost("child")] public async Task> PostAddChild(AuthChild authChild) { GenericResponse genericResponse = new GenericResponse(); if (authChild.SessionID != "id") { return Unauthorized(); } else if (authChild.SocSecNum == "111111111") { genericResponse.Status = Status.Error; genericResponse.Body["reason"] = "SSN Already exists!"; } else { genericResponse.Body["childID"] = "asdfaasdas"; } return genericResponse; } } }