using AppLibs.Libs; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using TWASys_App.Models; namespace TWASys_App.Controllers { [AllowAnonymous] public class LoginController : Controller { [Layout(LayoutOptions.Custom, "Login")] [PageInfor("10001", "Login")] public async Task Index() { return await this.ViewAsync(); } [HttpPost] public async Task SignIn([FromForm] UserModel user) { if (user.Username is not null && user.Password is not null && user.Username.Length > 0 && user.Password.Length > 0) { await Task.Delay(100); if (user.Username.ToLower().Equals("admin") && user.Password.Equals("TWA@2025")) { HttpContext.Session.SetString("userID", "admin"); return Json(new MessageHeader { ID = 10003, Message = "Login Success", Status = 1 }); } return Json(new MessageHeader { ID = 10002, Message = "The username or password you entered is incorrect", Status = 0 }); } return Json(new MessageHeader { ID = 10001, Message = "The username and password are required", Status = 0 }); } } }