/// <summary> /// Save new settings for MM user/tenant /// </summary> /// <param name="settings"></param> /// <param name="connectionString"></param> /// <param name="sessionTicket"></param> /// <param name="transaction"></param> /// <returns></returns> public string SaveAppSettings(AppSettings settings, string connectionString, string sessionTicket, out TransactionalInformation transaction) { var method = MethodInfo.GetCurrentMethod(); var ipInfo = Util.GetIPInfo(HttpContext.Current.Request); bool password_verified = false; transaction = new TransactionalInformation(); var userSecurityTicket = VerifySessionToken(sessionTicket); try { //check credentials try { IAccountServiceProvider accountService; var _providerFactory = ProviderFactory.Instance; accountService = _providerFactory.CreateAccountServiceProvider(); ChangePasswordRequest request = new ChangePasswordRequest(); request.NewPassword = settings.Password; request.OldPassword = settings.Password; request.TenantID = userSecurityTicket.TenantID; var account = accountService.GetAllAccountsForTenant(userSecurityTicket.TenantID).Where(acc => acc.ID == settings.AdminUser).FirstOrDefault(); if (account != null) { request.Email = account.Email; password_verified = accountService.ChangePassword(request).ChangedAccounts.FirstOrDefault() != null; } } catch (Exception ex) { if (ex is SDKServiceException) { transaction.ReturnMessage = new List <string>(); ServiceErrror errorMessage = (ServiceErrror) new JavaScriptSerializer().Deserialize(ex.Message, typeof(ServiceErrror)); if (errorMessage.Code == 70211) { transaction.ReturnStatus = true; password_verified = true; } else { transaction.ReturnStatus = false; transaction.ReturnMessage.Add(errorMessage.DeveloperMessage); transaction.IsAuthenicated = true; transaction.IsException = true; password_verified = false; } } else { Logger.LogInfo(new LogEntry(ipInfo.address, ipInfo.agent, connectionString, method, userSecurityTicket, ex)); throw new Exception("Something went wrong", ex); } } if (password_verified) { //save settings P_MD_SCS_1700 parameter = new P_MD_SCS_1700(); parameter.AccountID = settings.AdminUser; parameter.Email = settings.Email; parameter.OrderInterval = settings.OrderInterval; parameter.ImmediateOrderInterval = settings.ImmediateOrderInterval; AppSettings previous_state = null; Thread detailsThread = new Thread(() => GetCompanySettingsPreviousDetails(out previous_state, connectionString, userSecurityTicket)); detailsThread.Start(); cls_Save_Company_Settings.Invoke(connectionString, parameter, userSecurityTicket); Logger.LogInfo(new LogEntry(ipInfo.address, ipInfo.agent, connectionString, method, userSecurityTicket, settings, previous_state)); } else { return("password invalid"); } } catch (Exception ex) { Logger.LogInfo(new LogEntry(ipInfo.address, ipInfo.agent, connectionString, method, userSecurityTicket, ex)); transaction.ReturnMessage = new List <string>(); string errorMessage = ex.Message; transaction.ReturnStatus = false; transaction.ReturnMessage.Add(errorMessage); transaction.IsAuthenicated = true; transaction.IsException = true; } return("ok"); }
public bool VerifyDoctorPassword(string connectionString, string password, Guid doctor_id, string SessionToken, out TransactionalInformation transaction) { bool password_verified = false; transaction = new TransactionalInformation(); var method = MethodInfo.GetCurrentMethod(); var ipInfo = Util.GetIPInfo(HttpContext.Current.Request); var securityTicket = VerifySessionToken(SessionToken); var data = cls_Get_Account_Information_with_PracticeID.Invoke(connectionString, securityTicket).Result; try { if (String.IsNullOrEmpty(password)) { throw new ArgumentNullException("Password cannot be empty!"); } var accountService = ProviderFactory.Instance.CreateAccountServiceProvider(); ChangePasswordRequest request = new ChangePasswordRequest(); request.NewPassword = password; request.OldPassword = password; request.TenantID = securityTicket.TenantID; var account = cls_Get_Doctor_AccountID_for_DoctorID.Invoke(connectionString, new P_DO_GDAIDfDID_1549() { DoctorID = doctor_id }, securityTicket).Result; if (account != null) { var doctor_account = accountService.GetAllAccountsForTenant(securityTicket.TenantID).FirstOrDefault(acc => acc.ID == account.accountID); if (doctor_account != null) { request.Email = doctor_account.Email; password_verified = accountService.ChangePassword(request).ChangedAccounts.Any(); } } } catch (Exception ex) { if (ex is SDKServiceException) { transaction.ReturnMessage = new List <string>(); ServiceErrror errorMessage = (ServiceErrror) new JavaScriptSerializer().Deserialize(ex.Message, typeof(ServiceErrror)); if (errorMessage.Code == 70211) { transaction.ReturnStatus = true; password_verified = true; } else { transaction.ReturnStatus = false; transaction.ReturnMessage.Add(errorMessage.DeveloperMessage); transaction.IsAuthenicated = true; transaction.IsException = true; password_verified = false; } return(password_verified); } else { Logger.LogDocAppInfo(new LogEntry(ipInfo.address, ipInfo.agent, connectionString, method, securityTicket, ex), data.PracticeName); transaction.ReturnMessage = new List <string>(); string errorMessage = ex.Message; transaction.ReturnStatus = false; transaction.ReturnMessage.Add(errorMessage); transaction.IsAuthenicated = true; transaction.IsException = true; } } return(password_verified); }
public bool VerifyPassword(string email, string password, string connectionString, string sessionTicket, out TransactionalInformation transaction) { var method = MethodInfo.GetCurrentMethod(); var ipInfo = Util.GetIPInfo(HttpContext.Current.Request); bool password_verified = false; transaction = new TransactionalInformation(); var userSecurityTicket = VerifySessionToken(sessionTicket); try { IAccountServiceProvider accountService; var _providerFactory = ProviderFactory.Instance; accountService = _providerFactory.CreateAccountServiceProvider(); ChangePasswordRequest request = new ChangePasswordRequest(); request.NewPassword = password; request.OldPassword = password; request.TenantID = userSecurityTicket.TenantID; request.Email = email; password_verified = accountService.ChangePassword(request).ChangedAccounts.FirstOrDefault() != null; } catch (Exception ex) { if (ex is SDKServiceException) { transaction.ReturnMessage = new List <string>(); ServiceErrror errorMessage = (ServiceErrror) new JavaScriptSerializer().Deserialize(ex.Message, typeof(ServiceErrror)); if (errorMessage.Code == 70211) { transaction.ReturnStatus = true; password_verified = true; } else { transaction.ReturnStatus = false; transaction.ReturnMessage.Add(errorMessage.DeveloperMessage); transaction.IsAuthenicated = true; transaction.IsException = true; password_verified = false; } return(password_verified); } else { Logger.LogInfo(new LogEntry(ipInfo.address, ipInfo.agent, connectionString, method, userSecurityTicket, ex)); transaction.ReturnMessage = new List <string>(); string errorMessage = ex.Message; transaction.ReturnStatus = false; transaction.ReturnMessage.Add(errorMessage); transaction.IsAuthenicated = true; transaction.IsException = true; } } return(password_verified); }