private void Login_Button_Click(object sender, RoutedEventArgs e) { try { btnLogin.IsEnabled = false; IsAuthorized = false; var userObect = new Security.Manager.UserManager(oCommonUtilities.CreateInstance().GetConnectionString()); if ((txtUname.Text.ToUpper() == "CASH" && txtPWD.Password.ToUpper() == "DESK") || (txtUname.Text.ToUpper() == "BALLY" && CheckBallyuser(txtUname.Text, txtPWD.Password))) { IsAuthorized = true; User = userObect.GetUserObject(txtUname.Text, txtUname.Text, txtUname.Text); } else { var oSecurityAuthenticate = new BallySecurityAuthentication(); User = userObect.GetUserProfileByName(txtUname.Text); if (User != null && User.Password == CryptoHelper.CreateHash(txtPWD.Password) && SecurityHelper.HasAccess(User, Permission)) { IsAuthorized = true; } } if (!IsAuthorized) { MessageBox.ShowBox("MessageID289"); } Hide(); } catch (Exception ex) { ExceptionManager.Publish(ex); MessageBox.ShowBox("MessageID289"); } finally { btnLogin.IsEnabled = true; } }
private void Login_Button_Click(object sender, RoutedEventArgs e) { try { btnLogin.IsEnabled = false; IsAuthorized = false; var userObect = new Security.Manager.UserManager(oCommonUtilities.CreateInstance().GetConnectionString()); if ((txtUname.Text.ToUpper() == "CASH" && txtPWD.Password.ToUpper() == "DESK") || (txtUname.Text.ToUpper() == "BALLY" && CheckBallyuser(txtUname.Text, txtPWD.Password))) { IsAuthorized = true; User = userObect.GetUserObject(txtUname.Text, txtUname.Text, txtUname.Text); } else { var oSecurityAuthenticate = new BallySecurityAuthentication(); User = userObect.GetUserProfileByName(txtUname.Text); if (User != null && User.Password == CryptoHelper.CreateHash(txtPWD.Password) && SecurityHelper.HasAccess(User, Permission)) IsAuthorized = true; } if (!IsAuthorized) MessageBox.ShowBox("MessageID289"); Hide(); } catch (Exception ex) { ExceptionManager.Publish(ex); MessageBox.ShowBox("MessageID289"); } finally { btnLogin.IsEnabled = true; } }
private void LoginApplication() { try { AuditViewerBusiness.CreateInstance(oCommonUtilities.CreateInstance().GetConnectionString()); if (txtUname.Text.ToUpper() == "CASH" && txtPWD.Password.ToUpper() == "DESK") { var userObect = new Security.Manager.UserManager(oCommonUtilities.CreateInstance().GetConnectionString()); SecurityHelper.CurrentUser = userObect.GetUserObject(txtUname.Text, txtUname.Text, txtUname.Text); SecurityHelper.CurrentUser.UserName = txtUname.Text; SecurityHelper.CurrentUser.SecurityUserID = 0; SecurityHelper.CurrentUser.User_No = 0; ExtensionMethods.CurrentCurrenyCulture = ConfigManager.Read("GetDefaultCultureForCurrency"); ExtensionMethods.CurrentDateCulture = ConfigManager.Read("GetDefaultCultureForDate"); if (!IsLicenseValid()) { //Close(); Clear(); return; } var objMainScreen = new MainScreen { UserName = txtUname.Text }; objMainScreen.LoginInstance = this; objMainScreen.Show(); Close(); objMainScreen.DisposeLoginInstanceIfAny(); } else if (txtUname.Text.ToUpper() == "BALLY" && CheckBallyuser(txtUname.Text, txtPWD.Password)) { SecurityHelper.CreateInstance(oCommonUtilities.CreateInstance().GetConnectionString(), false); var userObect = new Security.Manager.UserManager(oCommonUtilities.CreateInstance().GetConnectionString()); SecurityHelper.CurrentUser = userObect.GetUserObject(txtUname.Text, txtUname.Text, txtUname.Text); SecurityHelper.CurrentUser.UserName = txtUname.Text; SecurityHelper.CurrentUser.SecurityUserID = 0; ExtensionMethods.CurrentCurrenyCulture = ConfigManager.Read("GetDefaultCultureForCurrency"); ExtensionMethods.CurrentDateCulture = ConfigManager.Read("GetDefaultCultureForDate"); if (!IsLicenseValid()) { Clear(); return; } var objMainScreen = new MainScreen { UserName = txtUname.Text }; objMainScreen.LoginInstance = this; objMainScreen.Show(); Close(); objMainScreen.DisposeLoginInstanceIfAny(); } else { var loginResult = Checkuser(txtUname.Text, txtPWD.Password); if (loginResult == SecurityHelper.LoginResults.LoginSuccesful) { ((App)Application.Current).CurrentCultureName = SecurityHelper.GetCultureInfo(SecurityHelper.CurrentUser.SecurityUserID); ExtensionMethods.CurrentCurrenyCulture = SecurityHelper.GetCurrencyCultureInfo(SecurityHelper.CurrentUser.SecurityUserID); ExtensionMethods.CurrentDateCulture = SecurityHelper.GetDateCultureInfo(SecurityHelper.CurrentUser.SecurityUserID); if (string.IsNullOrEmpty(ExtensionMethods.CurrentCurrenyCulture)) ExtensionMethods.CurrentCurrenyCulture = ConfigManager.Read("GetDefaultCultureForCurrency"); if (string.IsNullOrEmpty(ExtensionMethods.CurrentDateCulture)) ExtensionMethods.CurrentDateCulture = ConfigManager.Read("GetDefaultCultureForDate"); GetInitialSettings(); GetAppSettings(); if (!IsLicenseValid()) { Clear(); return; } var objMainScreen = new MainScreen { UserName = SecurityHelper.CurrentUser.UserName }; objMainScreen.LoginInstance = this; objMainScreen.Show(); GetConnectedSites(); Audit("Login Successful for User-" + SecurityHelper.CurrentUser.DisplayName); Close(); objMainScreen.DisposeLoginInstanceIfAny(); } else { if (loginResult == SecurityHelper.LoginResults.IsUserTerminated) { MessageBox.ShowBox("MessageID446", BMC_Icon.Error); Audit("Account Terminated for User-" + txtUname.Text); } else if ((loginResult == SecurityHelper.LoginResults.PasswordExpired) || (loginResult == SecurityHelper.LoginResults.LoginReset)) { if (loginResult == SecurityHelper.LoginResults.PasswordExpired) { MessageBox.ShowBox("MessageID267", BMC_Icon.Information); Audit("Password expired for User-" + txtUname.Text); } else { MessageBox.ShowBox("MessageID268", BMC_Icon.Information); Audit("Password Reset for User-" + txtUname.Text); } var passwordRetry = new PasswordRetry(SecurityHelper.CurrentUser.SecurityUserID); if (passwordRetry.ShowDialogEx(this) == true) { ((App)Application.Current).CurrentCultureName = SecurityHelper.GetCultureInfo(SecurityHelper.CurrentUser.SecurityUserID); ExtensionMethods.CurrentCurrenyCulture = SecurityHelper.GetCurrencyCultureInfo(SecurityHelper.CurrentUser.SecurityUserID); ExtensionMethods.CurrentDateCulture = SecurityHelper.GetDateCultureInfo(SecurityHelper.CurrentUser.SecurityUserID); if (string.IsNullOrEmpty(ExtensionMethods.CurrentCurrenyCulture)) ExtensionMethods.CurrentCurrenyCulture = ConfigManager.Read("GetDefaultCultureForCurrency"); if (string.IsNullOrEmpty(ExtensionMethods.CurrentDateCulture)) ExtensionMethods.CurrentDateCulture = ConfigManager.Read("GetDefaultCultureForDate"); GetInitialSettings(); GetAppSettings(); if (!IsLicenseValid()) { Clear(); return; } var objMainScreen = new MainScreen { UserName = SecurityHelper.CurrentUser.UserName }; objMainScreen.Owner = this; objMainScreen.Show(); Hide(); } } else if (loginResult == SecurityHelper.LoginResults.MaxAttemptsExceeded) { MessageBox.ShowBox("MessageID269", BMC_Icon.Error); Audit("Account Locked for User-" + txtUname.Text); } else { MessageBox.ShowBox("MessageID3"); Audit("Invalid Login attempt for User-" + txtUname.Text); } } } } catch (Exception ex) { ExceptionManager.Publish(ex); MessageBox.ShowBox("MessageID3"); } }