public bool Exec(LocalNetwork network, DtoLoginInformation dto, ref DtoAuthenticatedUser loggedUser) { try { if (!ValidadeRequest(dto)) { return(false); } using (var db = GetConnection(network)) { var user = repository.GetUserByEmail(db, dto.email); if (user == null) { Error = new DtoServiceError { message = getLanguage(dto._language, 1), debugInfo = "user == null" }; return(false); } if (user.stPassword != dto.password) { Error = new DtoServiceError { message = getLanguage(dto._language, 1), debugInfo = "user.stSenha != login.senha" }; return(false); } if (user.bActive != true) { Error = new DtoServiceError { message = getLanguage(dto._language, 1), debugInfo = "!user.bActive" }; return(false); } if (user.bTokenized != true) { Error = new DtoServiceError { message = getLanguage(dto._language, 1), debugInfo = "!user.bActive" }; return(false); } user.dtLastLogin = DateTime.Now; repository.UpdateUser(db, user); loggedUser._id = user.id.ToString(); loggedUser.email = user.stEmail; loggedUser.login = user.stName; } return(true); } catch (Exception ex) { Error = new DtoServiceError { message = getLanguage(dto._language, 0), debugInfo = ex.ToString() }; return(false); } }