/// <summary> /// Gets list object of the table UserApplication. /// </summary> /// <param name="lFilterUserApplication">List that contains the DTOs from UserApplication table that filter the query.</param> /// <returns>List object of the table UserApplication.</returns> /// <author>Mauricio Suárez.</author> public List <UserApplicationDto> GetUserApplication(UserApplicationDto dtoUserApplication) { List <UserApplicationDto> listFilterUserApplication = new List <UserApplicationDto>(); listFilterUserApplication.Add(dtoUserApplication); return(this.ExecuteGetUserApplication(null, listFilterUserApplication)); }
/// <summary> /// Save or update records for the table /// </summary> /// <param name="listDataUserApplication">List of data to store UserApplication.</param> /// <returns>The result of processing the list.</returns> /// <author>Mauricio Suárez.</author> public List <UserApplicationDto> SaveUserApplication(UserApplicationDto dtoUserApplication) { List <UserApplicationDto> listDataUserApplication = new List <UserApplicationDto>(); listDataUserApplication.Add(dtoUserApplication); return(this.SaveUserApplication(listDataUserApplication)); }
public ResultDto AuthenticationChangePassword(ChangePasswordDto dtoChangePassword) { ResultDto dtoresult = new ResultDto(); dtoresult.ResultCod = Convert.ToInt16(AuthenticationCode.AccessDenied); dtoresult.Message = "AccessDenied"; try { dtoChangePassword.UserName = Crypto.DecryptStringAes(dtoChangePassword.UserName); dtoChangePassword.Password = Crypto.DecryptStringAes(dtoChangePassword.Password); dtoChangePassword.NewPassword = Crypto.DecryptStringAes(dtoChangePassword.NewPassword); BasicAuthenticationDto dtoBasicAuthentication = GetBasicAuthentication(dtoChangePassword.UserName, dtoChangePassword.Password, dtoChangePassword.IdCompany, dtoChangePassword.IdApplication, dtoChangePassword.Token); if (dtoBasicAuthentication.AuthenticationCod == Convert.ToInt16(AuthenticationCode.Success) && !string.IsNullOrEmpty(dtoChangePassword.NewPassword)) { UserApplicationDto dtoUserApplication = new UserApplicationDto(); dtoUserApplication.UserName = dtoChangePassword.UserName; dtoUserApplication.UserPassword = dtoChangePassword.Password; dtoUserApplication.State = true; dtoUserApplication = UserApplicationRepository.GetUserApplication(dtoUserApplication).First(); dtoUserApplication.UserPassword = dtoChangePassword.NewPassword.ToUpper(); UserApplicationRepository.SaveUserApplication(dtoUserApplication); dtoresult.ResultCod = Convert.ToInt16(AuthenticationCode.Success); dtoresult.Message = "Success"; } } catch (Exception) { dtoresult.ResultCod = Convert.ToInt16(AuthenticationCode.AccessDenied); dtoresult.Message = "AccessDenied"; } return(dtoresult); }
private BasicAuthenticationDto GetBasicAuthentication(string userName, string password, long?idCompany, long?idApplication, string token) { bool authenticationError = false; BasicAuthenticationDto dtoResultUserAuthentication = new BasicAuthenticationDto(); dtoResultUserAuthentication.AuthenticationCod = Convert.ToInt16(AuthenticationCode.AccessDenied); dtoResultUserAuthentication.MessageAuthentication = "AccessDenied"; if (token != "not apply") { if (this.GetServiceToken() != token) { authenticationError = true; dtoResultUserAuthentication.MessageAuthentication = "AccessDenied"; } } if (String.IsNullOrEmpty(userName) || String.IsNullOrEmpty(password)) { authenticationError = true; dtoResultUserAuthentication.MessageAuthentication = "AccessDenied"; } if (authenticationError == false) { UserApplicationDto dtoUserApplication = new UserApplicationDto(); dtoUserApplication.UserName = userName; dtoUserApplication.UserPassword = password; dtoUserApplication.IdCompany = idCompany; dtoUserApplication.State = true; dtoUserApplication = UserApplicationRepository.GetUserApplication(dtoUserApplication).FirstOrDefault(); if (dtoUserApplication == null) { authenticationError = true; dtoResultUserAuthentication.MessageAuthentication = "AccessDenied"; } else { dtoUserApplication.UserPassword = null; if (dtoUserApplication.EffectiveDate != null && dtoUserApplication.EffectiveDate >= DateTime.Now) { authenticationError = true; dtoResultUserAuthentication.MessageAuthentication = "AccessDenied - Limit Date"; } else { dtoResultUserAuthentication.User = dtoUserApplication; } if (idCompany != null && authenticationError == false) { if (dtoResultUserAuthentication.User.IdCompany != idCompany) { authenticationError = true; dtoResultUserAuthentication.MessageAuthentication = "AccessDenied"; } } if (idApplication != null && authenticationError == false) { CompanyApplicationDto dtoApplication = new CompanyApplicationDto(); dtoApplication.IdApplication = idApplication; dtoApplication.IdCompany = dtoResultUserAuthentication.User.IdCompany; List <CompanyApplicationDto> listApplicationDto = CompanyApplicationRepository.GetCompanyApplication(dtoApplication); if (listApplicationDto.Count != 1) { authenticationError = true; dtoResultUserAuthentication.MessageAuthentication = "AccessDenied";// - ApplicationNotFound"; } } } } if (authenticationError == false) { dtoResultUserAuthentication.AuthenticationCod = Convert.ToInt16(AuthenticationCode.Success); dtoResultUserAuthentication.MessageAuthentication = "Success"; } return(dtoResultUserAuthentication); }