public async Task <IActionResult> Login([FromBody] LoginDTO model) { await Task.Yield(); User loggedUser = await sessionLogic.ValidateLogin(model.Email, model.Password).ConfigureAwait(false); if (loggedUser == null) { return(BadRequest("Login error: Incorrect email or password")); } else { Session.LoggedUser = loggedUser; return(Ok(loggedUser.Id)); } }
public IActionResult Login([FromBody] LoginDTO model) { Admin loggedAdmin = sessionLogic.ValidateLogin(model.Email, model.Password); if (loggedAdmin == null) { return(BadRequest("Login error: Incorrect email or password")); } else { Session.LoggedAdmin = loggedAdmin; Log newLog = new Log(); newLog.Admin = loggedAdmin; newLog.Email = Session.LoggedAdmin.Email; newLog.Date = DateTime.Now; newLog.ActionType = "login"; this.logLogic.Add(newLog); return(Ok(adminLogic.GetByCondition(a => a.Email == model.Email))); } }