using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using System; using System.Threading.Tasks; using zero.Core; using zero.Core.Api; using zero.Core.Entities; namespace zero.Web.Controllers { [AllowAnonymous] public class AuthenticationController : BackofficeController { private IAuthenticationApi Api { get; set; } public AuthenticationController(IZeroConfiguration config, IAuthenticationApi api) : base(config) { Api = api; } /// /// Get the currently logged in user /// [AllowAnonymous] //[Authorize()] public async Task GetUser() { return Json(await Api.GetUser()); } /// /// Tries a login for a user with username/password /// [HttpPost, AllowAnonymous] public async Task LoginUser() { throw new NotImplementedException(); //User user = await Api.Login(model.Username, model.Password, model.RememberMe); //if (user == null) //{ // return AsError("Username or password is incorrect"); //} //await Api.SetLastSeen(user); //return Json(new //{ // IsSuccess = true, // User = new Results.User(user), // UserMap = await Api.GetUserMap() //}); } /// /// Logout for the current user /// [HttpPost] public async Task LogoutUser() { throw new NotImplementedException(); //await Api.Logout(); //return AsSuccess(); } } }